Hi Experts,
Good day. Need your advice and guidance.
1. Have Web application (.net 4) upgraded to (.net 4.8) 2. Migrated authentication from DB to using LDAP (AD)
so far all good, but how to?
1. make the password text box encrypted (as still can see/get the password from backend)
Thanks
Public Function AuthenticateUser(ByVal path As String, ByVal user As String, ByVal pass As String) As String
Try
Dim de As DirectoryEntry = New DirectoryEntry(path, user, pass, AuthenticationTypes.Secure)
Dim ds As DirectorySearcher = New DirectorySearcher(de)
Dim result As SearchResult = ds.FindOne()
If Not IsDBNull(result) Then
Return "True"
Else
Return "Wrong Username / Password"
End If
Catch ex As Exception
Return "Wrong Username / Password"
End Try
End Function
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim sb As New StringBuilder
Dim r As New Random
lblAlert.Text = ""
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("Login clicked : " & DateTime.Now.ToString())
End Using
Try
Dim strAD As String = "LDAP://xxxxxxxx.zz.local"
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("AD " & strAD & " : " & DateTime.Now.ToString())
End Using
Dim UserAccess As String = AuthenticateUser(strAD, txtUserName.Text.Trim, txtPassword.Text.Trim)
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("Username : " & txtUserName.Text.Trim & " Password : " & txtPassword.Text.Trim & " " & DateTime.Now.ToString())
End Using
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("Authenticated " & UserAccess & " : " & DateTime.Now.ToString())
End Using
If UserAccess = "True" Then
Response.Redirect("~/Main.aspx", False)
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("Success : " & Session("strID") & " " & Session("UserID") & " " & Session("Role") & " " & Session("AD") & " " & DateTime.Now.ToString())
End Using
Else
lblAlert.Text = UserAccess
'temp log file
Using writer As New StreamWriter(logFilePath, True)
writer.WriteLine("Failed : " & DateTime.Now.ToString())
End Using
End If
Catch ex As Exception
lblAlert.Text = ex.Message
End Try
End Sub