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:
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:

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"
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")

Set rs = Nothing


<br />


Open in new window

Thank you for your help
romsomIT DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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 MontyWeb Ninja at largeCommented:
try this:

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

Open in new window

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!
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

From novice to tech pro — start learning today.