I don't know much about LDAP, but after looking around the forum for awhile. I came up with this.
Dim ldapPath
As String =
"ldap://dbm.i2a2.purdue.edu/ou=identify,dc=purdue,dc=edu"
Dim qry As
String = "(uid=xxx)"
Dim de As DirectoryEntry =
New DirectoryEntry(ldapPath,
Nothing, Nothing, AuthenticationTypes.Anonymous)
Dim ds As DirectorySearcher =
New DirectorySearcher(de, qry,
New String() {"cn"})
'test3
Dim sr As SearchResult = ds.FindOne()
lblPost.Text = Str(sr.Properties(
"cn")(0))
Unfortunately, I keep getting an error on the FindOne method. I saw some other people had this, but I didn't find a solution. I'm not even sure how to test this to see if my ldap is correct, but according to some documentation it is.
Can someone point me in the right direction? This is a public server. It uses SSL for authentication requests which I'm not trying to do yet. So my next question will be, how do I provide a certificate, etc.
You didn't post the error message, but if you have transcribed your code correctly, you will need to change the 'ldap://' to 'LDAP://' as it is case-sensitive. Typically, this is the only part of anything in LDAP that is case-sensitive.
That fixed my 05 error. Now I just get an error with the LDAP server depending on authenticationtype. I've tried everything intellisense gives me and for .anonymous I get "the parameter is incorrect" and for everything else, i get "the server is not operational".
When I try from softerra, everything seems to work fine so I don't think the server is having any trouble.
Hmm... you say this is a public server? If you check your Softerra settings, is is listening on another port? I cannot connect to it, though the servername resolves. This could be because it is not listening to the default LDAP port. I would have to know
from Softerra what the port and options are to try and replicate.
In general, the only ones that you can use with non-AD/ADAM LDAP directories are .SecureSocketsLayer, .None, or sometimes .Anonymous. You should stick with .None unless you know you are using SSL.
I just checked with some admins and found out that in the documenation, when they say public, they mean to any university cluster. Thus, you wouldn't be able to see it or me. I had them add our web server as a box for access and now get a new error:
Exception Details: System.DirectoryServices.DirectoryServicesCOMException: The server is unwilling to process the request.
I'm not sure what that means. It's the same thing I have in softerra I believe. I know I don't seem to be providing much info. I believe this is server is running a version built on OpenLDAP.
Class login
Inherits System.Web.UI.Page
Public Sub LDAP1()
Dim ldapPath
As String =
"LDAP://dbm.i2a2.purdue.edu/ou=identify,dc=purdue,dc=edu"
Dim qry As
String = "(uid=sreiche)"
Dim de As DirectoryEntry =
New DirectoryEntry(ldapPath,
Nothing, Nothing, AuthenticationTypes.None)
Dim ds As DirectorySearcher =
New DirectorySearcher(de, qry,
New String() {"puid"})
Dim sr As SearchResult = ds.FindOne()
lblPost.Text = sr.Properties("puid")(0).ToString
End Sub
Protected Sub Page_Load(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Me.Load
LDAP1()
End Sub
End
Class
That is the codebehind. There is a label on the form in a content control. The master file is the default template when you create a new master file in 2005. If you would like me to post the .aspx and the .master, let me know. I tried
this code with another working LDAP and it seemed to work. I'm sure the two aren't set up the same, but I'm not sure where to go from here. Again the error is on the .findone line.
It fails on the .findone line. There doesn't seem to be a difference whether I use nothing or empty string.
I talked to an admin and he said despite the documentation (and my tests with softerra) that I must use SSL. Now with SSL, I can connect, but according the logs he sent me, it connects and then immediately disconnects. The error I get is "the server is unwilling
to process the request" New code:
Public Sub LDAP1()
Dim ldapPath
As String =
"LDAP://dbm.i2a2.purdue.edu:636/ou=identify,dc=purdue,dc=edu"
Dim qry As
String = "(uid=sreiche)"
Dim de As DirectoryEntry =
New DirectoryEntry(ldapPath,
"", "", AuthenticationTypes.SecureSocketsLayer)
Dim ds As DirectorySearcher =
New DirectorySearcher(de, qry,
New String() {"puid"})
Dim sr As SearchResult = ds.FindOne()
lblPost.Text = sr.Properties(
"puid")(0).ToString
End Sub
Another issue I found is that when I use LDAPS://, I get the 05 (unknown error) again on the .findone. This is getting frustrating.
Also, I should add that I got no answer back on anonymous-binds. I've tried both way I think. What I did to try to bind was use my username/pass (which has access) instead of the empty strings. It didn't seem to change anything error wise.
PurdueGuy
Member
140 Points
28 Posts
Unknown Error - talking to LDAP not AD
Oct 12, 2005 03:50 PM|LINK
I don't know much about LDAP, but after looking around the forum for awhile. I came up with this.
Dim ldapPath As String = "ldap://dbm.i2a2.purdue.edu/ou=identify,dc=purdue,dc=edu"
Dim qry As String = "(uid=xxx)" Dim de As DirectoryEntry = New DirectoryEntry(ldapPath, Nothing, Nothing, AuthenticationTypes.Anonymous) Dim ds As DirectorySearcher = New DirectorySearcher(de, qry, New String() {"cn"}) 'test3 Dim sr As SearchResult = ds.FindOne()lblPost.Text = Str(sr.Properties(
"cn")(0))Unfortunately, I keep getting an error on the FindOne method. I saw some other people had this, but I didn't find a solution. I'm not even sure how to test this to see if my ldap is correct, but according to some documentation it is.
Can someone point me in the right direction? This is a public server. It uses SSL for authentication requests which I'm not trying to do yet. So my next question will be, how do I provide a certificate, etc.
Thanks,
dunnry
Star
9098 Points
1806 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 12, 2005 06:36 PM|LINK
Weblog
The Book
LDAP Programming Help
PurdueGuy
Member
140 Points
28 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 13, 2005 03:22 PM|LINK
Thanks!
That fixed my 05 error. Now I just get an error with the LDAP server depending on authenticationtype. I've tried everything intellisense gives me and for .anonymous I get "the parameter is incorrect" and for everything else, i get "the server is not operational". When I try from softerra, everything seems to work fine so I don't think the server is having any trouble.
Any clue on this one?
thanks in advance!
dunnry
Star
9098 Points
1806 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 13, 2005 07:02 PM|LINK
In general, the only ones that you can use with non-AD/ADAM LDAP directories are .SecureSocketsLayer, .None, or sometimes .Anonymous. You should stick with .None unless you know you are using SSL.
Weblog
The Book
LDAP Programming Help
PurdueGuy
Member
140 Points
28 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 13, 2005 09:11 PM|LINK
I just checked with some admins and found out that in the documenation, when they say public, they mean to any university cluster. Thus, you wouldn't be able to see it or me. I had them add our web server as a box for access and now get a new error:
Exception Details: System.DirectoryServices.DirectoryServicesCOMException: The server is unwilling to process the request.
I'm not sure what that means. It's the same thing I have in softerra I believe. I know I don't seem to be providing much info. I believe this is server is running a version built on OpenLDAP.
Thanks dunnry!
dunnry
Star
9098 Points
1806 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 14, 2005 03:34 PM|LINK
Weblog
The Book
LDAP Programming Help
PurdueGuy
Member
140 Points
28 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 14, 2005 03:47 PM|LINK
Imports
SystemImports System.DirectoryServices
Partial
Class loginInherits System.Web.UI.Page Public Sub LDAP1()
Dim ldapPath As String = "LDAP://dbm.i2a2.purdue.edu/ou=identify,dc=purdue,dc=edu"
Dim qry As String = "(uid=sreiche)"
Dim de As DirectoryEntry = New DirectoryEntry(ldapPath, Nothing, Nothing, AuthenticationTypes.None)
Dim ds As DirectorySearcher = New DirectorySearcher(de, qry, New String() {"puid"})
Dim sr As SearchResult = ds.FindOne()
lblPost.Text = sr.Properties("puid")(0).ToString
End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LDAP1()
End Sub
End
ClassThat is the codebehind. There is a label on the form in a content control. The master file is the default template when you create a new master file in 2005. If you would like me to post the .aspx and the .master, let me know. I tried this code with another working LDAP and it seemed to work. I'm sure the two aren't set up the same, but I'm not sure where to go from here. Again the error is on the .findone line.
Thanks
dunnry
Star
9098 Points
1806 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 14, 2005 03:51 PM|LINK
Does it fail on the .FindOne() or on retrieving this 'puid' attribute? What happens if you pass empty strings instead of 'Nothing' in the constructor?
Weblog
The Book
LDAP Programming Help
PurdueGuy
Member
140 Points
28 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 17, 2005 07:34 PM|LINK
I talked to an admin and he said despite the documentation (and my tests with softerra) that I must use SSL. Now with SSL, I can connect, but according the logs he sent me, it connects and then immediately disconnects. The error I get is "the server is unwilling to process the request" New code:
Public Sub LDAP1() Dim ldapPath As String = "LDAP://dbm.i2a2.purdue.edu:636/ou=identify,dc=purdue,dc=edu" Dim qry As String = "(uid=sreiche)" Dim de As DirectoryEntry = New DirectoryEntry(ldapPath, "", "", AuthenticationTypes.SecureSocketsLayer) Dim ds As DirectorySearcher = New DirectorySearcher(de, qry, New String() {"puid"}) Dim sr As SearchResult = ds.FindOne()
lblPost.Text = sr.Properties(
"puid")(0).ToString End SubAnother issue I found is that when I use LDAPS://, I get the 05 (unknown error) again on the .findone. This is getting frustrating.
PurdueGuy
Member
140 Points
28 Posts
Re: Unknown Error - talking to LDAP not AD
Oct 17, 2005 07:36 PM|LINK
Thanks