Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

User Authentication with Classic ASP

Hi Experts,
With the attached code I can retrieve the logged in user's employee number if the Logon_User is in one of the following formats:
ABC\U123456
or
ABCDE\123456
or ABC\123456

123456 is the employee number that I need to capture. My problem is that sometimes the Logon_User is in the following format, and I cannot capture the employee number:
ABC\U123456.last_name.first_name

How could I change the code below in order the capture only 123456, and ignore everything starting with the dot


<%
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If
%>

<%
set rs = Server.CreateObject("ADODB.recordset")
Dim UserID
UserID = UCase(Request.ServerVariables("LOGON_USER"))
UserID = Replace(UCase(UserID), "\U", "\")
UserID = Mid( UserID, InStrRev( UserID, "\", -1, 1 ) + 1, Len( userID ) )
if InStr( UserID, "U" ) >= 0 then
    UserID = Replace( UserID, "U", "" )
end if

rs.Open "exec sp_Authentication'" & UserID & "'", Conn

do until rs.EOF
EMP_ID = rs("EMP_ID")

rs.MoveNext
loop
rs.Close
Set rs = Nothing
%>

<%=EMP_ID%>

<br />

<%=Request.ServerVariables("Logon_User")%>

Open in new window


Thank you for your help
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stefan Motz

ASKER

Hi Monty,
I was hoping to catch you with this one, because you know about it.
It is working fine now, thank you very much. I just added it to the rest of the code, and the results are what I expected.
Have a great day!