Click to See Complete Forum and Search --> : ASP & VBScript Question...


kwilliams
06-02-2004, 05:19 PM
Hello,

I'm new to ASP & VBScript, and I'm trying to do something that should be pretty simple. On our intranet site, I'm pulling the NT login, comparing it to a DB value, and showing the user any records that match their Username. In doing this, I need to use a Substring method to pull all characters after 10 characters as the Username. This is what I have so far:

<%
strLogin = Request.ServerVariables("LOGON_USER")
strUsername = strLogin.Substring(strLogin,10,50)%>

...but this isn't pulling my NT login value as it would with ASP & JavaScript.

For example, if my full login with domain was SERVERNAME\kwilliams, I would want to pull everything after the "\". How can I do this easily with using VBScript? Am I missing something in my code? Thanks for any input.

KWilliams

simflex
06-03-2004, 03:15 PM
ASP doesn't use substring.

You would need something like:

<%
strLogin = Request.ServerVariables("LOGON_USER")
strUsername = left(strLogin,10)
%>

kwilliams
06-03-2004, 03:30 PM
Hello again simflex,

It ended up being a permissions issue for that directory. I let my NA know, and he reset the permissions for that folder so that the "Request.ServerVariables" method would work. Thanks for your suggestion & quick reponse.

CrazyC115
06-03-2004, 10:17 PM
ASP/VBScript may not use SubString but it does use Mid()

Info on using the Mid() function (http://www.devguru.com/Technologies/vbscript/quickref/mid.html)

Same thing really...


<%
DIM strLogin, strUsername

strLogin = Request.ServerVariables("LOGON_USER")

' Capture everyting from position 10.
strUsername = MID(strLogin, 10)
%>

kwilliams
06-04-2004, 09:14 AM
Hi CrazyC115,

Thanks for the info. I'll make sure to keep that tip in my notes for future reference. I greatly appreciate your advice.

KWilliams

lmf232s
06-04-2004, 09:28 AM
Request.ServerVariables("LOGON_USER")
loginUser = Request.ServerVariables("LOGON_USER")
domainAndUser = Split(loginUser, "\")
if IsArray(domainAndUser) Then
loginUser = domainAndUser(UBound(domainAndUser))
else
loginUser = loginUser
end if

kwilliams
06-04-2004, 09:32 AM
Hi lmf232s,

I was wondering about the Split method. Thanks for the info. I'll put that tip away into my tip file also:)