DirectoryEntry AD query problem.

M

Magnus R

In VB.Net I'm trying to find out the names of what Administrative Groups
exist by querying Active Directory. The problem is when I try and query the
children of the key LDAP://CN=Administrative Groups, CN=ExchOrg,
CN=Microsoft Exchange, CN=Services, CN=Configuration, CN=domain, CN=com I
don't get anything except an error that the "Object doesn't exist on the
server." However when I bind to this LDAP path using LDP.exe I can see the
Administrative Group Names underneath the tree just fine and even drill in
to them.

Here's my code:

Dim TempDE As New DirectoryEntry("LDAP://CN=Administrative Groups,
CN=ExchOrg, CN=Microsoft Exchange, CN=Services, CN=Configuration, CN=domain,
CN=com")
Dim prop As DirectoryEntry
Dim propnm As String = String.Empty
Dim strv As String
Dim objv As Object

MessageBox.Show(TempDE.Name.ToString)
For Each prop In TempDE.Children
For Each strv In prop.Properties.PropertyNames
For Each objv In prop.Properties(strv)
propnm += strv & " : " & objv.ToString & vbCrLf
Next
Next
Next

If I change the LDAP path to LDAP://CN=Microsoft Exchange, CN=Services,
CN=Configuration, CN=domain, CN=com the code above works fine.
 
M

Magnus R

Well I figured it out and wanted to post so it may help others. The problem
was with permissions. Using the DirectoryEntry.Username and
DirectoryEntry.Password to pass enterprise admin credentials resolved the
issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top