rclayh
|
Posted: 10/15/2003, 12:00 PM |
|
Okay, I found how to get the windows login name, so now I want to be able to use that authenticated login to automatically login the user on my web application if the username is in the database otherwise I want them to get the login form. So does anyone know how I can load the login form, test to see if the username is in the database and then autolog them in. What event should I hook into? Use a response.redirect?
Thanks in advance.
|
|
|
rclayh
|
Posted: 10/16/2003, 6:34 AM |
|
Figured it out, and it's pretty simple really. You just add slightly modified login form code in the before show event of the login page. Here's what my code ended up looking like if anyone is interested...
'Autologin if possible
'Build the windows user name
Dim CurrentUser as String = Web.HttpContext.Current.User.Identity.Name.ToString()
'Need to split the CurrentUser at the \
Dim myIndex as Integer = CurrentUser.IndexOf("\")
CurrentUser = CurrentUser.Remove(0,myIndex + 1)
Dim myUserPassword as String = Settings.conHelpDeskSQLDataAccessObject.ExecuteScalar("SELECT UserPassword FROM Personnel WHERE UserName='"& CurrentUser & "'").ToString
If DBUtility.CheckUser(CurrentUser, myUserPassword) Then
If Not(HttpContext.Current.Request("ret_link") is Nothing) Then
If Not(HttpContext.Current.Request("ret_link")="") Then
Response.Redirect(HttpContext.Current.Request("ret_link"))
End If
End If
End If
|
|
|
|