Hello,
I have this public function, but I just want to call it from the login page when it’s click. Can you show me how I can do that please?
This is the public function.
Public Function AuthenticateEmployee(ByVal Username As String, ByVal Password As String) As Boolean
Try
Dim Entry As System.DirectoryServices.DirectoryEntry = New System.DirectoryServices.DirectoryEntry("LDAP://csufacad.fullerton.edu", Username, Password)
Dim nativeObject As Object = Entry.NativeObject 'Authenticate username and password
Return True 'Correct credentials
Catch
Return False 'Incorrect credentials
End Try
End Function
This is the login page.
Protected Sub Login1_LoggedIn(sender As Object, e As System.EventArgs) Handles Login1.LoggedIn
Dim connString As String = ConfigurationManager.ConnectionStrings("DBHUSRConnectionString").ConnectionString
Dim DBConnection As SqlConnection = New SqlConnection(connString)
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim thisUserName As String
If DropDownList1.SelectedValue = "AD" Then
DBConnection.Open()
DBCommand = New SqlCommand("QGlobalUserRecords_sp", DBConnection)
DBCommand.CommandType = CommandType.StoredProcedure
DBCommand.Parameters.AddWithValue("@UserID", Login1.UserName())
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
If Login1.UserName = DBReader("WM_UserName") Then
thisUserName = DBReader("WM_Comments")
Select Case thisUserName
Case "Agency"
Response.Redirect("~/Agency/Agency.aspx")
Case "Admins"
Response.Redirect("~/Admin/Default.aspx")
Case "STUHUSR"
Response.Redirect("~/Advising/StudentRecord.aspx")
Case "Faculty"
Response.Redirect("~/Faculty/Faculty.aspx")
End Select
End If
End While
End If
If DropDownList1.SelectedValue = "ACAD" Then
Response.Redirect("~/Student/StudentAssignment.aspx")
End If
DBConnection.Close()
End Sub
thanks