ADSI Authentication from Visual Basic

From: Jim Dahrouge (Jim.Dahrouge@McKesson.COM)
Date: 02/13/03


From: "Jim Dahrouge" <Jim.Dahrouge@McKesson.COM>
Date: Thu, 13 Feb 2003 06:33:53 -0800


In simple terms, in a VB app, I'm prompting for a Domain,
Username, and Password from a user and I want to verify
that the information entered relates to a valid user
and "authenticate" them.

I'm trying to do so as follows (based off of an MSDN
article):

    Dim dso As IADsOpenDSObject
    Dim domain As IADsDomain
    Dim szUsername As String
    Dim szPassword As String
    Dim szDomain As String
    
    On Error GoTo Cleanup
   
    szDomain = "DOMAIN NAME" ' Validate against Domain
' szDomain = "LOCAL MACHINE NAME" 'Validate against
local machine.
    szUsername = "USERNAME"
    szPassword = "PASSWORD"
    
    Set dso = GetObject("WinNT:")
    Set domain = dso.OpenDSObject("WinNT://" + szDomain,
szUsername, szPassword, ADS_SECURE_AUTHENTICATION)
    
Cleanup:
        If (Err.Number <> 0) Then
            MsgBox ("An error has occurred. " & Err.Number)
        End If
        Set dso = Nothing
        Set domain = Nothing

Notes:
1) This code works fine when I authenticate against a
domain.
2) When I try to authenticate a local user, I set the
szDomain to the local machine name and I continually get
RTE 13 (Type Mismatch).
 



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)
  • Re: Creating remote objects
    ... >> This creates an instance of Word on the local machine from Excel 2000, ... I don't have a remote server to go against. ... >> (ByVal lpszIID As String, ByVal piid As Long) As Long ... >> Dim rclsid As GUID ...
    (microsoft.public.excel.programming)
  • Re: LDAP Auth Problem - COM interop
    ... I'm trying to use LDAP to authenticate users. ... Public Function IsAuthenticated(ByVal domain As String, ... Dim entry As DirectoryEntry = New DirectoryEntry(_path, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Listing, adding, and removing users to a local or domain group
    ... This code will list the users on the local machine using the ... Purpose: This will list the users in a domain. ... Dim domainDirectory As New DirectoryEntry ... directorySearcher.PropertiesToLoad.AddRange(New String() {"givenName", ...
    (microsoft.public.windows.server.active_directory)
  • 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)