Re: LDAP Auth Problem - COM interop



There should be more details of the COM error in the stack trace. Can you
provide that? Also, that sample from MS kind of sucks. We have a much
better one in our book (IMO) in ch 12. Ch 12 isn't the free chapter from
the website, but the code samples are there for download.

LDAP auth is a thorny problem that can get you into trouble. Are you sure
you need to do it this way? Also, can you use the .NET 2.0
ActiveDirectoryMembershipProvider instead?

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Chris Davoli" <ChrisDavoli@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7A98D5F7-9CA5-4471-9A14-3BB8AFCCCB52@xxxxxxxxxxxxxxxx
Environment: Win XP, VS2003, Active Directory
I'm trying to use LDAP to authenticate users. I used article
http://support.microsoft.com/?id=326340
How to authenticate against the Active Directory by using forms
authentication and Visual Basic .NET, but am having a COM interop error
when
I do the IsAuthenticated try to create an object entry.NativeObject ie;
Dim
obj As Object = entry.NativeObject

The COM interop error is <error: an exception of type:
{System.Runtime.InteropServices.COMException} occurred>

I'm thinking that there is some kind of COM component that is either not
registered, or not there.

Can anyone help me?

Here is the code:

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
End Function



--
Chris Davoli



.



Relevant Pages

  • Re: Authenticating to a service
    ... service and our remote client application calls the authenticate method ... ''' Authenticate a user against the network's users. ... Public Shared Function Authenticate(ByVal userName As String, ... Dim tokenHandle As New IntPtr ...
    (microsoft.public.dotnet.languages.vb)
  • ADSI Authentication from Visual Basic
    ... and "authenticate" them. ... Dim domain As IADsDomain ... Dim szUsername As String ... szDomain to the local machine name and I continually get ...
    (microsoft.public.security)
  • Re: Active Directory LDAP Authentication Fails in IIS 6
    ... in IIS 5.1) were: ... It seems you can't Authenticate using the Active Directory thats why you ... Public Function IsAuthenticated(ByVal domain As String, ... Dim entry As DirectoryEntry = New DirectoryEntry(_path, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Declaring array in Stored Procedures
    ... There are no arrays in T-SQL. ... Dim oConn_User as New ADODB.Connection ... Dim sConStr as String ... in which i have to authenticate user, if user is authenticated then i ...
    (comp.lang.basic.visual.misc)
  • LDAP Auth Problem - COM interop
    ... I'm trying to use LDAP to authenticate users. ... I do the IsAuthenticated try to create an object entry.NativeObject ie; Dim ... Public Function IsAuthenticated(ByVal domain As String, ... The requested authentication method is not supported by the server ...
    (microsoft.public.dotnet.framework.interop)