ASP to LDAP - try this ...

Discussion in 'ASP .Net' started by Support, Feb 24, 2005.

  1. Support

    Support Guest

    If you call DirectoryEntry with hardcoded password ("in this case
    "password")- this will work but if you pass mypassword instead it will fail
    ...
    Dim theusername as string ="someting", thepassword as string="somethingelse"
    Response.Write(DoYouExist(theusername,thepassword).ToString())

    This is strange behavior ....

    Imports System.DirectoryServices

    Private Function DoYouExist(ByVal myusername As String, ByVal mypassword As
    String) As Boolean

    Dim entry As New DirectoryEntry(LDAP://whatever, myusername ,"password")
    Dim mySearcher = New DirectorySearcher(entry)
    Dim results As SearchResultCollection
    Dim MySearchAccount As String = "SAMAccountName=ArchieBald"
    mySearcher.Filter = (MySearchAccount)
    results = mySearcher.FindAll()
    Dim result As SearchResult
    Try
    results = mySearcher.FindAll()
    Catch ex As Exception
    DoYouExist = False
    Exit Function
    End Try
    If results.Count > 0 Then DoYouExist = True Else DoYouExist = False
    End Function
     
    Support, Feb 24, 2005
    #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. bienwell
    Replies:
    4
    Views:
    3,885
    bienwell
    May 27, 2005
  2. John Salerno
    Replies:
    20
    Views:
    871
    John Salerno
    Aug 11, 2006
  3. Fabio Z Tessitore

    who is simpler? try/except/else or try/except

    Fabio Z Tessitore, Aug 12, 2007, in forum: Python
    Replies:
    5
    Views:
    389
  4. =?Utf-8?B?QUo=?=

    When to TRY and not to TRY

    =?Utf-8?B?QUo=?=, Oct 16, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    342
    sloan
    Oct 17, 2007
  5. MRAB
    Replies:
    4
    Views:
    319
Loading...

Share This Page