Вот мой пример подобного от одного старого проекта, возвращает ФИО, по логину в AD:
private const string Domain = "<b>DOMAINNAME</b>";
static readonly DirectoryEntry Entry = new DirectoryEntry("LDAP://" + Domain);
static readonly DirectorySearcher Dsearch = new DirectorySearcher(Entry);
static SearchResultCollection _sResultSetCol;
public string GetAdFIOfromLogin(string fio)
{
try
{
fio = fio;
Dsearch.Filter = "(&(<b>samaccountname</b>=" + fio + "))";
_sResultSetCol = Dsearch.FindAll();
try
{
foreach (SearchResult sResultSet in _sResultSetCol)
{
if (GetProperty(sResultSet, "samaccountname") == fio)
{
return GetProperty(sResultSet, "<b>name</b>");
}
}
}
catch (Exception e)
{
return e.Message;
}
}
catch (Exception e)
{
return e.Message;
}
return "";
}
Вот названия полей:
submissioncontlength
logoncount
cn
msexchuseraccountcontrol
msexchrbacpolicylink
streetaddress
msexchpoliciesincluded
info
company
postalcode
adspath
userprincipalname
instancetype
st
physicaldeliveryofficename
msexchtextmessagingstate
showinaddressbook
otherpager
samaccountname
manager
msexchrecipientdisplaytype
distinguishedname
memberof
msexchelcmailboxflags
objectcategory
mailnickname
legacyexchangedn
objectclass
proxyaddresses
msexchalobjectversion
samaccounttype
homemdb
msexchhomeservername
telephonenumber
initials
countrycode
delivcontlength
co
publicdelegatesbl
givenname
name
msexchmailboxtemplatelink
l
badpwdcount
department
displayname
textencodedoraddress
useraccountcontrol
homemta
c
msexchuserculture
mail
title
primarygroupid
codepage
sn