1
votes

Im working in a migration project.

Where im trying to migrate classic asp application. Im not good at Classic ASP.

i had taken the code from the server and trying to run it in my machine. But getting the following error.

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '[number: 1]'

/Include/Security.inc, line 28

Please find the block of code where im getting the error.

Function StringConvUN
    dim tabConv
    dim rmLocation
    dim username
    username = Ucase(Request.ServerVariables("LOGON_USER"))
    if UCase(Request.ServerVariables("HTTP_AUTHORIZATION")) = "SITEMINDER" then
        StringConvUN = username
    else
        tabConv = split(username, "'")
        rmLocation = join(tabConv, "''")
        tabConv = split(rmLocation , "\")
        StringConvUN = tabConv(1)
    end if
End Function

Im getting the error in line 28 which is

StringConvUN = tabConv(1)

The same code is running fine in the IIS 6 server. But in my machine and in new IIS 7.5 server it giving the above error. please help me on this.

3

3 Answers

2
votes

You may want to check to see whether you're using the correct authentication method in IIS, as well as what Amessihel has mentioned above. But the code looks a little messy here...

tabConv = split(username, "'")
rmLocation = join(tabConv, "''")
tabConv = split(rmLocation , "\")
StringConvUN = tabConv(1)

Why not just Replace your single quotes with doubles in the initial copy of the Request.ServerVariables("LOGON_USER"), like so:

username = Replace(Request.ServerVariables("LOGON_USER"), "'", "''")

And you could simply use a combination of Instr and Mid to obtain the string you want...

tabconv = Mid(UCase(Replace(Request.ServerVariables("LOGON_USER"), "'",   "''")), _
  Instr(Request.ServerVariables("LOGON_USER"), "\") + 1)

But check IIS first.

0
votes

You should check if StringConvUN is empty before getting the first element...

See this answer. This is a home-made function checking if an array is empty.

-2
votes

Instead of looking for position 1 in the array, which in this case does not exist, try taking the last position in the array, i.e. everything after the '\'

StringConvUN = tabConv(uBound(tabConv))