Results 1 to 40 of 73

Thread: Validate Login against Active Directory

Hybrid View

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Validate Login against Active Directory

    Ok. np
    Lets do this in stages.
    So to use the code as it stands now, just validating the user (no group code yet), we would use something like:
    Code:
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
       Dim authenticated As Boolean = AuthenticateUser()
       If isAuthenticated Then
          'some code here to open app
          Me.Close()
       Else
          'code here to display incorrect login details
       End If
    End Sub
    
    Private Function AuthenticateUser() As Boolean
       Dim username As String = txtUsername.Text
       Dim password As String = txtPassword.Text
       Dim domain As String = 'this can be in a config file, hard coded (I wouldnt do that), or inputed from the UI
    
       Dim isAuthenticated As Boolean = ValidateActiveDirectoryLogin(username, password, domain)
    
       Return isAuthenticated
    End Function
    Hope this helps.

    Woka

  2. #2
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Validate Login against Active Directory

    Hi mate. Thanks for your time tonight.

    Ok so i have copied your code into the form.

    It may just be a typo but is Dim authenticated not supposed to be Dim isauthenticated

    Code:
    Dim authenticated As Boolean = AuthenticateUser()
       If isAuthenticated Then
    Other small issues that vb.net is throwing up are

    txtUserNames is not declared
    txtPasswords is not declared

    on line

    Dim domain As String = 'this can be in a config file, hard coded (I wouldnt do that), or inputed from the UI

    it is moaning about the = saying expression expected.

    Also it is moaning about Name 'ValidateActiveDirectoryLogin' is not declared.

    Code:
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
       Dim authenticated As Boolean = AuthenticateUser()
       If isAuthenticated Then
          'some code here to open app
          Me.Close()
       Else
          'code here to display incorrect login details
       End If
    End Sub
    
    Private Function AuthenticateUser() As Boolean
       Dim username As String = txtUsername.Text
       Dim password As String = txtPassword.Text
       Dim domain As String = 'this can be in a config file, hard coded (I wouldnt do that), or inputed from the UI
    
       Dim isAuthenticated As Boolean = ValidateActiveDirectoryLogin(username, password, domain)
    
       Return isAuthenticated
    End Function
    Thanks

    Craig Wallace

    Active Directory Administrator \ Designer

    SMS 2003 Administrator

    Everything else Networks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width