var ldapUrl = new LdapUrl("ldap://myserver.mydomain.com:389/dc=mydomain,dc=com"); var connection = new LdapConnection(ldapUrl); connection.Authenticate("cn=MyUser,dc=mydomain,dc=com", "MyPassword", LdapAuthenticationMode.Simple);
var searchBase = "ou=Users,dc=mydomain,dc=com"; var searchFilter = "(&(objectClass=user)(memberOf=cn=Administrators,cn=Builtin,dc=mydomain,dc=com))"; var searchScope = LdapSearchScope.Subtree; var attributesToRetrieve = new[] {"samAccountName", "cn", "mail"}; var searchRequest = new LdapSearchRequest(searchBase, searchFilter, searchScope, attributesToRetrieve); var searchResponse = connection.SendRequest(searchRequest) as LdapSearchResponse; foreach (var resultEntry in searchResponse.Entries) { var samAccountName = resultEntry.Attributes["samAccountName"].StringValue; var displayName = resultEntry.Attributes["cn"].StringValue; var email = resultEntry.Attributes["mail"].StringValue; Console.WriteLine($"{samAccountName} - {displayName} - {email}"); }Package library: The Brainsbits.LDA Conexion library is not a package from a specific package library, but rather a custom library developed by Brainsbits.