Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > DirectoryEntry works for anonymous, but not for usern/pass

Reply
Thread Tools

DirectoryEntry works for anonymous, but not for usern/pass

 
 
Brian Stevenson
Guest
Posts: n/a
 
      07-24-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DirectoryEntry.NativeObject slow with ASP.Net, but fast in exe Vadim P ASP .Net Security 3 01-21-2006 03:14 AM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
ldap DirectoryServices.DirectoryEntry System.NotImplementedException: Handling of this ADSVALUE type is not yet implemented (type = 0xb). m96 ASP .Net Web Services 4 02-22-2005 06:11 AM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments