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.
Help to find Address from ADS
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Craig MurphyRank #2,956 · 488 reputationPosted Apr 6, 2006, 12:22 AM EDT
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