locked
CRM users image from AD RRS feed

  • Question

  • Hi

    Where do i add this code this code for updating crm users image from AD?

                var directoryEntry = new DirectoryEntry("LDAP://" + domain, adminusername, adminpassword);
                var directorySearcher = new DirectorySearcher(directoryEntry);
    
                directorySearcher.Filter = string.Format("(&(SAMAccountName={0}))", updateduserdomainname);
                var user = directorySearcher.FindOne();
                int count = ((System.Collections.ReadOnlyCollectionBase)(user.Properties["thumbnailPhoto"])).Count;
    
                if (count > 0)
                {
                    var bytes = user.Properties["thumbnailPhoto"][0] as byte[];
                    Entity updateentity = new Entity("your entity name");
                    updateentity.Id = "entityid";
                    updateentity["entityimage"] = bytes;
                    service.Update(updateentity);
                }

    Tuesday, April 26, 2016 11:21 AM

All replies