473,382 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 14182

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
0
by: microsoft | last post by:
Hi People, when I try to modify an active directory user programatically, I receive the following exception: The server is unwilling to process the request Reading the microsoft web site, I...
9
by: Mario Rodriguez | last post by:
Hi people. I have a problem adding users to Win2003 active directory programatically. When I execute my app throws the following exception: .................The specified directory service...
4
by: ASGMikeG | last post by:
Hi, How do I find the user object for the current user in Active Directory i.e. the user running my program ? Regards Michael
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
0
by: RTT | last post by:
here is my current situation. I develop a program on my computer's localhost. From there i contact Active directory succesfull using a connectionstring like:...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.