Of course, you can do this in System.DirectoryServices.
I think you really need to learn how to use System.DirectoryServices . If you do not have a good book yet, I recommend this one .
, . , DirectoryEntry DirectorySearcher. DirectoryEntry LDAP LDAP. , , LDAP, , DirectoryEntry. LDAP . , , - objectCategory objectClass. objectCategory person, objectClass contact. "targetAddress" , . Exchange. , , . LDAP, , AD Explorer ADSI
, DirectorySearcher.
, , .
DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
string domainContext = rootDSE.Properties["defaultNamingContext"].Value as string;
DirectoryEntry searchRoot = new DirectoryEntry("LDAP://" + domainContext);
using (DirectorySearcher searcher = new DirectorySearcher(
searchRoot,
"(&(objectCategory=person)(objectClass=contact))",
new string[] {"targetAddress"},
SearchScope.Subtree))
{
foreach (SearchResult result in searcher.FindAll())
{
foreach (string addr in result.Properties["targetAddress"])
{
Console.WriteLine(addr);
}
Console.WriteLine(result.Path);
}
}
LDAP . , . LDAP , DirectoryEntry.
DirectorySearcher. , , .NET .
, DiectorySearcher, SearchResult, , SearchResult , targetAddress . , LDAP .
, SearchResult, Path. DirectoryEntry, . , Properties CommitChanges.
DirectoryEntry de = new DirectoryEntry(result.Path);
de.Properties["targetAddress"].Value = "SMTP:jane.doe@foo.bar";
de.CommitChanges();
, - DirectorySearcher, DirectoryEntry. Google.