+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Consuming LDAP Property Mappings in user control

Consuming LDAP Property Mappings in user control

3 posts, 0 answered
  1. Marshall
    Marshall avatar
    1 posts
    Registered:
    16 Nov 2012
    18 Jul 2013
    Link to this post
    How can I consume a new LDAP property mapping object in a user control? There is a few fields that I would like to access that I am not sure how. 
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    18 Feb 2015
    Link to this post
    did you ever figure this out? is there any docs that describe how to get LDAP properties from Sitefinity?
  3. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    23 Feb 2015
    Link to this post
    Hi all,

    @Josh

    I believe we discussed a similar topic in our support thread correspondence. It concerned how to get LDAP Property Mappings in a Custom UserProfile field. The methodology of adding them to a user control is the same. Basically you will need to get the mapping via the configurations of your LDAP and then you are free to manipulate the data retrieved. Here is the sample from the support thread:

    "For the sake of this sample the property names you define in the Sitefintiy LDAP user mappings should contain the "profile_" prefix and have the same names as the fields in the user profile. So for example if you want to synchronize the custom field "Country" in the user profile with the country information form your AD, when you define the mapping for this LDAP field you have to name your property "profile_Country"." 

    var userManager = UserManager.GetManager("LdapUsers");
                var users = userManager.GetUsers();
                var ldapFacade = new LdapFacade();
                var mapping = Config.Get<SecurityConfig>().LdapConnections.LdapMapping.UserMapping;
                var ldapProfileMappingKeys = mapping.PropertiesMapping.Keys.Where(k => k.Contains("profile_"));
       
                foreach (var user in users)
                {
                    var ldapUser = ldapFacade.GetUserById(user.Id, new string[1]);
                    Dictionary<string, string> profileFieldsProxy = new Dictionary<string, string>();
                    foreach (var key in ldapProfileMappingKeys)
                    {
                        var fieldValue = LdapUtilities.GetAttributeValue<string>(ldapUser, mapping.GetLdapFieldName(key));
                        profileFieldsProxy.Add(key.Replace("profile_", ""), fieldValue);
                    }
                    
                }


    Regards,
    Ivan D. Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
3 posts, 0 answered