C# Получение данных из Active Directory
private const string Domain = "DomainName"; readonly DirectoryEntry Entry = new DirectoryEntry("LDAP://" + Domain); readonly DirectorySearcher Dsearch = new DirectorySearcher(Entry); SearchResultCollection _sResultSetCol; string username="iamuser"; Dsearch.Filter = "(&(samaccountname=" + iamuser+ "))"; _sResultSetCol = Dsearch.FindAll(); foreach (SearchResult sResultSet in _sResultSetCol) { return GetProperty(sResultSet, "name"); }
Комментарии