I need to get some information from users in a database that is stored in Active Directory, I have a simple function for this:
using (DirectoryEntry de = new DirectoryEntry("LDAP://ANYGIVENDOMAIN"))
{
using (DirectorySearcher adSearch = new DirectorySearcher(de))
{
adSearch.Filter = "(sAMAccountName=jdoe)";
SearchResult adSearchResult = adSearch.FindOne();
StringBuilder sb = new StringBuilder();
sb.AppendLine(adSearchResult.Properties["displayname"][0].ToString());
sb.AppendLine(adSearchResult.Properties["givenName"][0].ToString());
sb.AppendLine(adSearchResult.Properties["objectSid"][0].ToString());
sb.AppendLine(adSearchResult.Properties["description"][0].ToString());
sb.AppendLine(adSearchResult.Properties["objectGUID"][0].ToString());
}
}
Starting from WinForm is done the way I want, but in SQL Server Project Type I cannot add the System.DirectoryServices namespace to the links.
Does anyone know why?
Hi
Je
source
share