VB.NET LDAP query HELP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code to show all members of a domain
global group that is selected from a drop down list. I
can display the property "member" just fine which shows a
listing like:

CN=Jones\, Bill, CN=Group, OU=domain
However, I need to go a step further and display other
information about a user such as phone number, building,
etc. Is there anyway to find the information I need from
AD with what is returned form the property "Member". Or
is there a better way for me to do this?

Thanks

Dim groupEntry As New DirectoryEntry("LDAP://" &
ddl_ggselect.SelectedValue)
Dim entryMembers As PropertyValueCollection
entryMembers = groupEntry.Properties("Member")

Dim memberValue As Object
For Each memberValue In entryMembers

Response.Write(memberValue & "<br>")
'Right here I need to go a step further and
connect to the memberValue variable to return more
information about the retrieved user.


Next
 
However, I need to go a step further and display other
information about a user such as phone number, building,
etc. Is there anyway to find the information I need from
AD with what is returned form the property "Member".

Yes - take the string (the user's "DN" - distinguishedName) that
member returns, and then add LDAP:// to its beginning, and bind to
that object - here's a sample in C# - should be easy to translate to
VB.NET:

DirectoryEntry deGroup = new DirectoryEntry("LDAP://" + strGroupName);

foreach(object oUser in deGroup.Properties["member"])
{
string strUserPath = "LDAP://" + oUser.ToString();

DirectoryEntry deUser = new DirectoryEntry(strUserPath);
if(deUser != null)
{
Console.WriteLine("User's full name: " +
deUser.Properties["givenName"].Value + " " +
deUser.Properties["sn"].Value);
}
}

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top