Re: Error trying form authentication against AD
From: Edward Henn (henne@saccourt.com.no.spam)
Date: 04/01/03
- Previous message: Neil Mc: "forms authentication cookie problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Edward Henn" <henne@saccourt.com.no.spam> Date: Tue, 1 Apr 2003 08:39:13 -0800
I encountered many problems when first trying this code to get to AD. Took
some time for me to find the right connection string to reach AD.
First thing you should do is verify you are using the right connection
string. You can look at Active Directory with one of the native tools to
verify where the user you are searching for is located, if you need to
specify an OU, etc. Good luck.
Ed Henn
Sacramento Superior Court
"Beginner" <bzhang@hotmail.com> wrote in message
news:O#Z3r5HzCHA.2296@TK2MSFTNGP10...
> I'm trying the samples in Q326340. When calling function
IsAuthenticated(),
> if I try wrong name or password, the error message is "Unkonw user" by
Throw
> Exception; If I give the right name and password, search.FindOne() returns
> nothing.
>
> Seems it did connected to LDAP server, but just could get result. What
> could be the problem? Thanks.
>
>
> Public Function IsAuthenticated(ByVal domain As String, ByVal
> username As String, ByVal pwd As String) As Boolean
>
> Dim domainAndUsername As String = domain & "\" & username
> Dim entry As DirectoryEntry = New DirectoryEntry(_path,
> domainAndUsername, pwd)
>
> Try
> 'Bind to the native AdsObject to force authentication.
> Dim obj As Object = entry.NativeObject
> Dim search As DirectorySearcher = New
> DirectorySearcher(entry)
>
> search.Filter = "(SAMAccountName=" & username & ")"
> search.PropertiesToLoad.Add("cn")
> Dim result As SearchResult = search.FindOne()
>
> If (result Is Nothing) Then
> Return False
> End If
>
> 'Update the new path to the user in the directory.
> _path = result.Path
> _filterAttribute = CType(result.Properties("cn")(0),
String)
>
> Catch ex As Exception
> Throw New Exception("Error authenticating user. " &
> ex.Message)
> End Try
>
> Return True
>
>
- Previous message: Neil Mc: "forms authentication cookie problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|