DirectoryEntry works for anonymous, but not for usern/pass

Discussion in 'ASP .Net Security' started by Brian Stevenson, Jul 25, 2003.

  1. 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
    Brian Stevenson, Jul 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    3
    Views:
    754
    F. GEIGER
    Aug 6, 2004
  2. Reporter
    Replies:
    3
    Views:
    462
    Mike Schilling
    May 12, 2007
  3. Vadim P
    Replies:
    3
    Views:
    1,125
    Joe Kaplan \(MVP - ADSI\)
    Jan 21, 2006
  4. Trans
    Replies:
    2
    Views:
    156
    Trans
    Aug 30, 2005
  5. Replies:
    1
    Views:
    212
Loading...

Share This Page