I am trying to come up with 2 DropDownLists, one employee DropDownList and the other, manager DropDownList.
First, I am not familiar with how Active Directory works but having done some research, I did find something like the code below which as I understand, represents Manager definition:
What group represents manager in Active Directory?
The bigger issue for me though is if I select employee from the first dropDownList, how does it populate the second dropDownList
with the manager of that employee?
From what I undersand, department is the attribute that relates employee to manager but how do I use this in code?
In normal cascading dropdownlist, I can select employee and list the department the employee belongs to in the first dropdownlist and in the second dropdownlist, I can select manager where department = theDepartmentListed in first dropdownlist.
That's querying the database but in my case, we are querying the Active Directory.
Can someone please show how to link the relationship between employee in first dropDownList and manager in the second dropDownList based on department?
Um, I think you are slightly off on where manager actually comes from. In AD, manager is an attribute of an Active Directory User object, it isn't an org unit like you are thinking it is. Unless you make the manager the org unit it won't essentially work
like that.
Sure, what you would want to LDAP query on is the attribute instead of an organization unit as such. Read the article that the link goes to for a more clear explanation but in the nuts and bolts of it:
(AttributeName=*yourtexthere*) replacing AttributeName with the name of the attribute
(as defined by ldapDisplayName) and |replacing yourtexthere with the search criteria such as in the following examples:
(physicalDeliveryOfficeName=*Seattle*) or in your case, (Manager = "Doe, John")
Hard coding manager's names like (Manager="Doe, John")
For instance, when I select an employee from the first dropdownlist, we would like the manager of that employee to populate the second dropdownlist.
So, instead of (cn="manager="doe, john"), what would replace doe, john?
Please see example below for what I currently have.
Dim deEmployee As New DirectoryEntry("LDAP://CN=John Employee,OU=Sales,DC=Corp,DC=com")
deEmployee.[Property]("manager") = "CN=Peter Manager,OU=Sales,DC=Corp,DC=com"
deEmployee.CommitChanges()
Then run another AD query using the "manager" property for the query to show all users based upon that property. Below is a link that involves troubleshooting to find details by propertyname.
simflex
Member
69 Points
248 Posts
How can I display Employee's Manager?
Feb 13, 2013 08:05 PM|LINK
I am trying to come up with 2 DropDownLists, one employee DropDownList and the other, manager DropDownList.
First, I am not familiar with how Active Directory works but having done some research, I did find something like the code below which as I understand, represents Manager definition:
What group represents manager in Active Directory?
The bigger issue for me though is if I select employee from the first dropDownList, how does it populate the second dropDownList
with the manager of that employee?
From what I undersand, department is the attribute that relates employee to manager but how do I use this in code?
In normal cascading dropdownlist, I can select employee and list the department the employee belongs to in the first dropdownlist and in the second dropdownlist, I can select manager where department = theDepartmentListed in first dropdownlist.
That's querying the database but in my case, we are querying the Active Directory.
Can someone please show how to link the relationship between employee in first dropDownList and manager in the second dropDownList based on department?
bbcompent1
All-Star
32996 Points
8510 Posts
Moderator
Re: How can I display Employee's Manager?
Feb 13, 2013 08:24 PM|LINK
Um, I think you are slightly off on where manager actually comes from. In AD, manager is an attribute of an Active Directory User object, it isn't an org unit like you are thinking it is. Unless you make the manager the org unit it won't essentially work like that.
simflex
Member
69 Points
248 Posts
Re: How can I display Employee's Manager?
Feb 13, 2013 08:59 PM|LINK
Thank you very much bbcompent1 for your prompt response.
I have struggled with this for quite sometime.
Would you be kind enough to give me an example of how this should work?
bbcompent1
All-Star
32996 Points
8510 Posts
Moderator
Re: How can I display Employee's Manager?
Feb 13, 2013 09:04 PM|LINK
Sure, what you would want to LDAP query on is the attribute instead of an organization unit as such. Read the article that the link goes to for a more clear explanation but in the nuts and bolts of it:
http://support.microsoft.com/kb/224543?wa=wsignin1.0
simflex
Member
69 Points
248 Posts
Re: How can I display Employee's Manager?
Feb 13, 2013 11:34 PM|LINK
Thanks,
That's exactly where my problem lies.
Hard coding manager's names like (Manager = "Doe, John")
For instance, when I select an employee from the first dropdownlist, we would like the manager of that employee to populate the second dropdownlist.
So, instead of (cn="manager="doe, john"), what would replace doe, john?
Please see example below for what I currently have.
Dim deEmployee As New DirectoryEntry("LDAP://CN=John Employee,OU=Sales,DC=Corp,DC=com") deEmployee.[Property]("manager") = "CN=Peter Manager,OU=Sales,DC=Corp,DC=com" deEmployee.CommitChanges()bbcompent1
All-Star
32996 Points
8510 Posts
Moderator
Re: How can I display Employee's Manager?
Feb 19, 2013 04:16 PM|LINK
Hey simflex, I haven't forgotten you, been doing research on how to query the manager name by employee. I hope to have something for you soon.
bbcompent1
All-Star
32996 Points
8510 Posts
Moderator
Re: How can I display Employee's Manager?
Feb 19, 2013 04:26 PM|LINK
Ok, I think I have a theory on how you can do this. First of all, query the user's details and capture "manager" in a session variable.
http://www.aspdotnet-suresh.com/2011/03/how-to-get-userdetails-from-active.html
Then run another AD query using the "manager" property for the query to show all users based upon that property. Below is a link that involves troubleshooting to find details by propertyname.
http://stackoverflow.com/questions/13284782/find-all-users-in-ldap-using-asp-net-c-sharp