I need to obtain some information from the users in the database that is stored on Active Directory, I've a simple function to do 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());
}
}
Running from a WinForm do as I want, but in the SQL Server Project Type I can't add the namespace System.DirectoryServices to the references.
Anyone knows why ?
Regards
JE