Friday, 4 January 2013

Create LDAP connection with Active Directory


Custom Code while creating a LDAP connection with Active Directory and get the Information of all the users.

DirectoryEntry de = new DirectoryEntry();

//DC = DomainController here AD Domain is sharepoint.2010.com,
de.Path = "LDAP://10.1.1.1/DC=sharepoint,DC=2010,DC=com";
de.AuthenticationType = AuthenticationTypes.Secure;
searcher = new DirectorySearcher(de);
//searcher.Filter  filters all the information according to the filter query. Below filter gets all users
searcher.Filter = "(&(objectCategory=Person)(objectClass=User))";
searcher.SearchScope = SearchScope.Subtree;
searcher.PageSize = 1000;

No comments:

Post a Comment