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. Advertisements

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:
    4,148
    bienwell
    May 27, 2005
  2. Replies:
    1
    Views:
    721
    Raymond DeCampo
    Feb 21, 2006
  3. John Salerno
    Replies:
    20
    Views:
    1,229
    John Salerno
    Aug 11, 2006
  4. rcmn
    Replies:
    1
    Views:
    548
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  5. Fabio Z Tessitore

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

    Fabio Z Tessitore, Aug 12, 2007, in forum: Python
    Replies:
    5
    Views:
    675
  6. =?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:
    521
    sloan
    Oct 17, 2007
  7. MRAB
    Replies:
    4
    Views:
    511
  8. Jake Barnes
    Replies:
    2
    Views:
    279
    Jake Barnes
    Apr 7, 2006
Loading...