I'm racking my brain over this problem. I can get DirectoryEntry to
bind to a DirectoryEntry object anonymously without any problem, but
when I try to bind with a username and password, it doesn't work.
Environment:
Windows 2000 Server / IIS 5.0
Novell's LDAP server (running NetWare 5.1)
Code snippet:
Public Function Login() As Boolean
Dim root As New
System.DirectoryServices.DirectoryEntry("LDAP://10.99.5.92/O=Fishel","USERNAME","PASSWORD")
Dim searcher As New
System.DirectoryServices.DirectorySearcher(root)
searcher.Filter = "(&(objectClass=user)(cn= " & Me.Username &
"))"
Dim results As SearchResultCollection
results = searcher.FindAll()
Dim result As SearchResult
For Each result In results
' CODE TO BIND TO EACH OBJECT FOUND IN THE SEARCH AND TRY THE
USER'S USER/PASS COMBO. NOT YET WRITTEN.
Next result
End Function
The above code will work when I take out the "USERNAME" and
"PASSWORD", but when present, the following error for some attributes
in the local debug window reads:
Name <error: an exception of type:
System.Runtime.InteropServices.COMException} occurred> String
When is should read something like:
Name O=Fishel String
I also get the following error on the web form....
An invalid dn syntax has been specified
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An
invalid dn syntax has been specified
Stack Trace:
[COMException (0x80072032): An invalid dn syntax has been specified]
System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
+513
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObj ect() +10
System.DirectoryServices.DirectorySearcher.FindAll (Boolean
findMoreThanOne) +199
System.DirectoryServices.DirectorySearcher.FindAll () +10
TeamFishel.OWNS.BLL.Authenticate.Login() in T:\Home\Visual Studio
Projects\TeamFishel.OWNS.BLL\Authenticate.vb:57
TeamFishel.OWNS.WebUI.Login.loginButton_Click(Obje ct sender,
EventArgs e) in C:\Documents and
Settings\bgstevenson\VSWebCache\dotnet.intra.fishe lco.com\OWNS\Login.aspx.vb:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain() +1263
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.288;
ASP.NET Version:1.0.3705.288
Line #57 is:
results = searcher.FindAll()
Does anyone have any thoughts about why this is happening?
Sincerely,
Brian
|