Hi all
Please help me to get the "Address (street, country, P.O Box, City, Zip/Pin code )" from the Active Directory using c#.net.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Craig MurphyPosted Apr 6, 2006, 4:22 AM
using System.DirectoryServices;
…
DirectoryEntry directoryEntry = new DirectoryEntry(”LDAP://dc=DOMAIN_CONTEXT,dc=com”);
DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);
directorySearcher.Filter = “(&(objectCategory=person)(sAMAccountName=” + Environment.UserName + “))”;
DirectoryEntry result = directorySearcher.FindOne().GetDirectoryEntry();
string name = result.Properties[”displayName“].Value.ToString();
You will need to use Properties other than displayName, but they are all there.
From:
http://www.craigmurphy.com/blog/?p=237
HTH