M
Mr. Bean
Hello,
I'm trying to retrieve the user's properties from Active Directory. I
was able to retrieve all the user properties, however, I wassnt able
to get the manager's user name. What I got was the path of the user
name : CN="Display Name", CN=myCompany,CN=COM..
Here is the
private string[] FindProps(String userAccount)
{
DirectoryEntry entry = new
DirectoryEntry("LDAP://mypc.mydomain.com");
String account = userAccount.Replace(@"mydomain\", "");
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + account + ")";
search.PropertiesToLoad.Add("displayName");
search.PropertiesToLoad.Add("mail");
search.PropertiesToLoad.Add("department");
search.PropertiesToLoad.Add("title");
search.PropertiesToLoad.Add("manager");
SearchResult result = search.FindOne();
string[] props = new string[10];
props[0] = result.Properties["displayname"][0].ToString();
props[1] = result.Properties["mail"][0].ToString();
props[2] = result.Properties["department"][0].ToString();
props[3] = result.Properties["manager"][0].ToString();
props[4] = result.Properties["title"][0].ToString();
return props;
} function i used to retrieve all the user props.
I'm trying to retrieve the user's properties from Active Directory. I
was able to retrieve all the user properties, however, I wassnt able
to get the manager's user name. What I got was the path of the user
name : CN="Display Name", CN=myCompany,CN=COM..
Here is the
private string[] FindProps(String userAccount)
{
DirectoryEntry entry = new
DirectoryEntry("LDAP://mypc.mydomain.com");
String account = userAccount.Replace(@"mydomain\", "");
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + account + ")";
search.PropertiesToLoad.Add("displayName");
search.PropertiesToLoad.Add("mail");
search.PropertiesToLoad.Add("department");
search.PropertiesToLoad.Add("title");
search.PropertiesToLoad.Add("manager");
SearchResult result = search.FindOne();
string[] props = new string[10];
props[0] = result.Properties["displayname"][0].ToString();
props[1] = result.Properties["mail"][0].ToString();
props[2] = result.Properties["department"][0].ToString();
props[3] = result.Properties["manager"][0].ToString();
props[4] = result.Properties["title"][0].ToString();
return props;
} function i used to retrieve all the user props.