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

Forums / Developing with Sitefinity / LDAP User List Update

LDAP User List Update

6 posts, 1 answered
  1. Andy
    Andy avatar
    7 posts
    Registered:
    03 Oct 2012
    20 Mar 2015
    Link to this post

    I am trying to update every LDAP user (which are all using the Basic Profile).

    I want all "is public profile" to be updated to TRUE.

    I cannot seem to find specific documentation to do this...

    Basically the script to do this should:

    Loop through all users

    Change ispublic flag to TRUE

    Update profile.

    Thanks!!!!

    Answered
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    20 Mar 2015 in reply to Andy
    Link to this post

    Doc is right here: http://docs.sitefinity.com/for-developers-modify-user-profiles

     Obviously you could use usermanager to get all users and loop, or instead on the login event just set it to true for the user that just logged in (so more on demand)

  3. Andy
    Andy avatar
    7 posts
    Registered:
    03 Oct 2012
    20 Mar 2015 in reply to Steve
    Link to this post

    Hi Steve and thanks,

    I tried the following - I am starting off by simply updating the About field.

    This didn't affect anything.

     

            public static void GetAllProfilesAndUpdate()
            {
                var userManager = UserManager.GetManager();
                var users = userManager.GetUsers();

                foreach (var user in users)
                {
                    UserProfileManager profileManager = UserProfileManager.GetManager();
                    UserManager ldapUserManager = UserManager.GetManager("LdapUsers");

                    User account = ldapUserManager.GetUser(user.Id);
                    if (account != null)
                    {
                        SitefinityProfile profile = profileManager.GetUserProfile<SitefinityProfile>(account);
                        profile.SetValue("About", "Test From Program");
                        profileManager.SaveChanges();
                    }
                }
            }

  4. Andy
    Andy avatar
    7 posts
    Registered:
    03 Oct 2012
    22 Mar 2015
    Link to this post
    If anyone from Telerik can chime in here - it would be extremely helpful. I have an urgent project that needs this taken care of...I got 2000 users that I need to be "public"....thanks!!!
  5. Angel Moret
    Angel Moret avatar
    29 posts
    Registered:
    02 Dec 2016
    24 Mar 2015
    Link to this post
    Hello Andy,

    We have answered you in the support ticket that you opened for this topic. Feel free to share the information provided with the community. 
     
    Regards,
    Angel Moret
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  6. Andy
    Andy avatar
    7 posts
    Registered:
    03 Oct 2012
    31 Mar 2015 in reply to Angel Moret
    Link to this post

    FYI for everyone:
    LDAP users may show up in the Admin>User list, but unless someone has edited their profile, they do NOT have a Sitefinity profile yet. They must have profiles created for them before they are considered "public" to the system. 
    The code below should read LDAP users, and create a profile first, summarily setting each profile to Public.

    public static void GetAllProfilesAndUpdate()
     {
         var userManager = UserManager.GetManager("LdapUsers");
         var users = userManager.GetUsers();
     
         foreach (var user in users)
         {
             UserProfileManager profileManager = UserProfileManager.GetManager();
             SitefinityProfile profile = null;
             profile = profileManager.GetUserProfiles(user.Id).Where(p => p.GetType().FullName == typeof(SitefinityProfile).FullName).SingleOrDefault() as SitefinityProfile;
     
             if (user.LastName != "" && user.Email != null && profile == null)
             {
                 SitefinityProfile userProfile = null;
                 userProfile = profileManager.CreateProfile(user, Guid.NewGuid(), typeof(SitefinityProfile)) as SitefinityProfile;
                  
                 userProfile.SetValue("IsProfilePublic", true);
     
     
                 if (user.LastName != "")
                 {
                     profileManager.SaveChanges();
                 }                   
     
                 userManager.Provider.SuppressSecurityChecks = true;
                 userManager.SaveChanges();
                 userManager.Provider.SuppressSecurityChecks = false;
             } 
     
     
         }
     }

     

6 posts, 1 answered