468,784 Members | 1,536 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,784 developers. It's quick & easy.

Active directory

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.

May 27 '06 #1
8 13984

"Mr. Bean" <mk*****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
| 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.
|

This is normal, the Manager attribute is an Object(DS-DN) type attribute
that refers to the manager's user object. If you want the details of this
object you need to query it's properties.
I would suggest you to check the "Active Directory Schema" in the docs
before you start coding against the AD, it's fundamental that you understand
the formal definitions of the attributes of the objects you want to
retrieve.

Willy.
May 27 '06 #2
>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..


Yes, that's the way it was designed. If you need details for the
manager, you will now need to grab his DN (distinguishedName), bind to
it, and retrieve that user's properties.

Marc
May 27 '06 #3
Mr. Bean,

Here might help:
http://www.microsoft.com/technet/scr...r/hubs/ad.mspx

chanmm

"Mr. Bean" <mk*****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
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.

May 27 '06 #4
Mr. Bean wrote:
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 attached an example of something I threw together to do a quick search
of AD.

Jim
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There's no place like 127.0.0.1
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
JimD
Central FL, USA, Earth, Sol

May 27 '06 #5
thanks for your posts, I will review the code sample attached by JimD..

May 28 '06 #6
COuld some one please tell me the exact function to use inorder to
retrieve the user name of the manager. ie what I need is to be able to
retrieve the user's manager in this form: domain\user.

Please include code sample

May 29 '06 #7
"Mr. Bean" <mk*****@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
COuld some one please tell me the exact function to use inorder to
retrieve the user name of the manager. ie what I need is to be able to
retrieve the user's manager in this form: domain\user.

Please include code sample


You've already received an explanation as to how to do this...
May 29 '06 #8
I didnt figure out how to confiugure the code knowing that I read the
previous posts

May 29 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Mario Rodriguez | last post: by
4 posts views Thread by ASGMikeG | last post: by
1 post views Thread by Andrew | last post: by
6 posts views Thread by Leo_Surf | last post: by
1 post views Thread by tangus via DotNetMonster.com | last post: by
2 posts views Thread by Jim in Arizona | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.