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
romsomIT DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try this:

    if InStr( UserID, "." ) > 0 then
        UserID = Mid( UserID, InStr( UserID, "\" ) + 1, InStr( UserID, "." ) - InStr( UserID, "\" ) - 1 )
    else
        UserID = Right( UserID, Len( UserID ) - InStr( UserID, "\" ) )
    end if

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
romsomIT DeveloperAuthor Commented:
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!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.