DirectoryEntry works for anonymous, but not for usern/pass

B

Brian Stevenson

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(Boolean throwIfFail)
+513
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObject() +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(Object sender,
EventArgs e) in C:\Documents and
Settings\bgstevenson\VSWebCache\dotnet.intra.fishelco.com\OWNS\Login.aspx.vb:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top