Problem w/ DirectoryEntry-class in .NET

Problem w/ DirectoryEntry-class in .NET

Post by thilo.lang » Tue, 02 Dec 2003 21:10:57


hello,

the constructor for the DirectoryEntry-class doesn't seem
to work if i use the following syntax:

dim de as new directoryentry("ldap://cn=langbein\, thilo,
ou=user, dc=microsoft, dc=com")

the problem seems to be the "," with the escape-backslash.
can someone confirm, that there is a probelm with reserved
characters?

any ideas? thanks for your replies!

regards, thilo.
 
 
 

Problem w/ DirectoryEntry-class in .NET

Post by Marc Scheu » Tue, 02 Dec 2003 23:33:03

>the constructor for the DirectoryEntry-class doesn't seem

I think the problem is the fact you didn't UPPERCASE the LDAP on the
LDAP path string! It's case-sensitive - yes, it is!

Try:

dim de as new directoryentry("LDAP://cn=langbein\, thilo,
ou=user, dc=microsoft, dc=com")

Also, are you sure you really have an OU called "user" on your
machine? The standard "Users" container is just that - a generic
container, *NOT* an OU ! Thus you need to prefix it with cn=, not ou=
(and it's spelled "Users" with an s at the end)

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

 
 
 

Problem w/ DirectoryEntry-class in .NET

Post by anonymou » Wed, 03 Dec 2003 00:29:37

hi,

thanks for your reply. I used LDAP in uppercase; but not
in my mail. :-)

the problem is not the ldap-path!

I enumerate the users of a special ad-group. i initialize
for every entry in the the member-property (arryay) a new
directory-entry class to retrieve some values of that user.

should i post some more pieces of code?

reagrds, thilo.

seem
thilo,
LDAP on the
your
generic
cn=, not ou=
======
With You!
inova.ch
 
 
 

Problem w/ DirectoryEntry-class in .NET

Post by Marc Scheu » Wed, 03 Dec 2003 17:24:34

>the problem is not the ldap-path!

You're 150% positive on this? It usually is ;-)


Might be helpful, yes - try to cut out as much code as possible (which
is not really relevant - e.g. we don't need to see how you retrive 25
attributes - one will do :-)

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

Problem w/ DirectoryEntry-class in .NET

Post by Thil » Wed, 03 Dec 2003 23:27:56

here is the code:

Dim AdEntry As New DirectoryEntry
("LDAP://LAN", "LAN\user-id", "password")
Dim AdSearcher As New DirectorySearcher(AdEntry)
Dim AdResult As SearchResult
Dim AdResults As SearchResultCollection
Dim AdFound As DirectoryEntry
Dim AdMember As DirectoryEntry

Dim strMember As String

AdSearcher.Filter = "(&(objectCategory=group)
(name=ggpapp-tse-assetcenter))"
AdSearcher.SearchScope = SearchScope.Subtree
AdSearcher.PropertiesToLoad.Add("cn")
AdSearcher.PropertiesToLoad.Add("ditinguishedName")

AdResults = AdSearcher.FindAll()

For Each AdResult In AdResults
AdFound = AdResult.GetDirectoryEntry()
If AdFound.Properties.Contains("member") Then
For Each strMember In AdFound.Properties
("member")
'strMember = CN=Friese\, Patrick -
IT11PF,OU=Abteilung
IT,OU=Zentrale,OU=Abteilungsbenutzer,DC=lan,DC=huk-
coburg,DC=de
Debug.WriteLine(strMember)
AdMember = New DirectoryEntry
("LDAP://" & strMember, "LAN\user-id", "password")
If AdMember.Properties
("objectClass").Contains("user") Then
Debug.WriteLine("user: " &
AdMember.Properties("cn")(0))
ElseIf AdMember.Properties
("objectClass").Contains("group") Then
Debug.WriteLine("group: " &
AdMember.Properties("cn")(0))
End If
Next
End If
Next
 
 
 

Problem w/ DirectoryEntry-class in .NET

Post by Marc Scheu » Fri, 05 Dec 2003 16:28:36

>here is the code:

Thanks - and where exactly do you get what error message exactly??


Did you see this typo?? It should be "distinguishedName" (you missed
the s at the third position).

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

Problem w/ DirectoryEntry-class in .NET

Post by Thil » Fri, 05 Dec 2003 23:34:15

hi,

the missing "s" is not the probelm.
but the interesting thing that i found is:
if i use ...DirectoryEntry("GC://... (Global Catalog)
instead of ...DirectoryEntry("LDAP://... everything work's
perfect.

the exception error occurs at:
If AdMember.Properties("objectClass").Contains("user") Then

i will use the ldap-path with "GC".

regards, thilo.


exactly??
("ditinguishedName")
(you missed
======
With You!
inova.ch
 
 
 

Problem w/ DirectoryEntry-class in .NET

Post by Marc Scheu » Fri, 05 Dec 2003 23:55:29

>but the interesting thing that i found is:

Well, in that case, for some reason, your server-less binding might
not work. You could always try to use server-bound binding, e.g.

LDAP://yourserver.company.com/cn=John
Doe,cn=Users,dc=yourcompany,dc=com

Of course, you're "hard-coding" your access to a a specific server
this way.

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