Oke ones you got the current user you will have to connect to Active
directory and get the properties you want. Here is some code that will do
just that.
/// <summary>
/// Connects to the Active Directory and retrieves the value of the
property asked for.
/// </summary>
/// <param name="PropertyName">Name of the property to retrieve the value
for.</param>
/// <returns>Value of the proeprty, string.empty if property not
found.</returns>
internal string getADirectoryValue(string PropertyName)
{
try
{
DirectoryEntry directoryEntry = new DirectoryEntry(@"LDAP://" +
_aDDomain, _aDLogonUser,_aDLogonUserPassword );
DirectorySearcher directorySearcher = new
DirectorySearcher(directoryEntry);
SearchResult searchResult;
directorySearcher.Filter = "(anr=" + _userName + ")";
searchResult = directorySearcher.FindOne();
DirectoryEntry foundEntry = searchResult.GetDirectoryEntry();
return foundEntry.Properties[PropertyName].Value.ToString();
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine(string.Concat(
"Active Directory Property with name : ",
PropertyName,
" Not found or Active Directory logon failed:",
ex.ToString()));
return string.Empty;
}
}
--
Rainier van Slingerlandt
www.slingerlandt.com
Please hit the Yes button If my effort is helpfull.