ASP & Active Directory

Discussion in 'ASP General' started by Hermes, Sep 30, 2004.

  1. Hermes

    Hermes Guest

    Hi all,

    We have a web page which validates users againt active directory (kinda),
    Effectively the code we use will check the user's password and if successful
    creates some session's for what access they have in the internal site. We
    have noticed though that the query against the LDAP doesnt seem to
    disconnect and by doing a netstat -a we get alot of ports with an
    ESTABLISHED status on the LDAP server. When this gets to around 200 it goes
    verrrrrrrrrrrrryyyyyyyyy slow on the site. If we do an unload on the IIS
    they get released and goes back to normal speed.

    e.g.
    TCP IISbox:4597 ldap.domainname.co.uk:ldap ESTABLISHED
    TCP IISbox:4649 ldap.domainname.co.uk:ldap ESTABLISHED
    TCP IISbox:4652 ldap.domainname.co.uk:ldap ESTABLISHED
    TCP IISbox:4664 ldap.domainname.co.uk:ldap ESTABLISHED

    The following is the code,

    <%@ Language = VBScript %>
    <%
    on error resume next
    Dim strADsPath
    Dim strUserName
    Dim strPassword
    Dim iFlags
    Dim strFullADsPath
    Dim strFullUserName
    Dim strADsNamespace
    Dim oADsNamespace
    Dim oADsObject
    Session.Timeout=480
    session("username") = request.form("username")
    strADsPath = "DOMAIN-NAME"
    strUserName = Request.Form("UserName")
    strPassword = Request.Form("Password")
    iFlags = "0"
    strFullADsPath = "WinNT://"&strADsPath
    strFullUserName = strADsPath&"\"&strUserName
    Set oADsObject = GetObject(strFullADsPath)
    strADsNamespace = left(strFullADsPath, instr(strFullADsPath, ":"))
    set oADsNamespace = GetObject(strADsNamespace)
    Set oADsObject = oADsNamespace.OpenDSObject(strFullADsPath,
    strFullUserName, strPassword, 0)
    if err.number = 0 then
    Session("user_logged_in") = "true"
    strUserName = session("username")
    Set oUser = GetObject("WinNT://" & strADsPath & "/" & strUserName &
    ",user")
    GetUserFullName = oUser.FullName
    if oGroup.Name = "Domain Admins" then
    session("Group1") = "true"
    session("Group2") = "true"
    session("Group3") = "true"
    end if
    set strADsPath = nothing
    set strUserName = nothing
    set strPassword = nothing
    set iFlags = nothing
    set strFullADsPath = nothing
    set strFullUserName = nothing
    set strADsNamespace = nothing
    set oADsNamespace = nothing
    set oADsObject = nothing
    Set oUser = nothing
    else
    Response.Redirect "denied_logout.asp"
    end if
    end if
    %>

    Any comments or suggestions are gladly welcome :eek:)
    Many thanks in advance,
    Rob
     
    Hermes, Sep 30, 2004
    #1
    1. Advertising

  2. Hermes

    Jeff Cochran Guest

    On Thu, 30 Sep 2004 19:14:53 +0000 (UTC), "Hermes" <>
    wrote:

    Have you tried closing your objects? As in:

    oADsObject.close
    oADsNamespace.close

    Jeff

    >We have a web page which validates users againt active directory (kinda),
    >Effectively the code we use will check the user's password and if successful
    >creates some session's for what access they have in the internal site. We
    >have noticed though that the query against the LDAP doesnt seem to
    >disconnect and by doing a netstat -a we get alot of ports with an
    >ESTABLISHED status on the LDAP server. When this gets to around 200 it goes
    >verrrrrrrrrrrrryyyyyyyyy slow on the site. If we do an unload on the IIS
    >they get released and goes back to normal speed.
    >
    >e.g.
    > TCP IISbox:4597 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4649 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4652 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4664 ldap.domainname.co.uk:ldap ESTABLISHED
    >
    >The following is the code,
    >
    ><%@ Language = VBScript %>
    ><%
    >on error resume next
    >Dim strADsPath
    >Dim strUserName
    >Dim strPassword
    >Dim iFlags
    >Dim strFullADsPath
    >Dim strFullUserName
    >Dim strADsNamespace
    >Dim oADsNamespace
    >Dim oADsObject
    >Session.Timeout=480
    > session("username") = request.form("username")
    > strADsPath = "DOMAIN-NAME"
    > strUserName = Request.Form("UserName")
    > strPassword = Request.Form("Password")
    > iFlags = "0"
    > strFullADsPath = "WinNT://"&strADsPath
    > strFullUserName = strADsPath&"\"&strUserName
    > Set oADsObject = GetObject(strFullADsPath)
    > strADsNamespace = left(strFullADsPath, instr(strFullADsPath, ":"))
    > set oADsNamespace = GetObject(strADsNamespace)
    > Set oADsObject = oADsNamespace.OpenDSObject(strFullADsPath,
    >strFullUserName, strPassword, 0)
    > if err.number = 0 then
    > Session("user_logged_in") = "true"
    > strUserName = session("username")
    > Set oUser = GetObject("WinNT://" & strADsPath & "/" & strUserName &
    >",user")
    > GetUserFullName = oUser.FullName
    > if oGroup.Name = "Domain Admins" then
    > session("Group1") = "true"
    > session("Group2") = "true"
    > session("Group3") = "true"
    > end if
    >set strADsPath = nothing
    >set strUserName = nothing
    >set strPassword = nothing
    >set iFlags = nothing
    >set strFullADsPath = nothing
    >set strFullUserName = nothing
    >set strADsNamespace = nothing
    >set oADsNamespace = nothing
    >set oADsObject = nothing
    >Set oUser = nothing
    > else
    > Response.Redirect "denied_logout.asp"
    > end if
    > end if
    >%>
    >
    >Any comments or suggestions are gladly welcome :eek:)
    >Many thanks in advance,
    >Rob
    >
     
    Jeff Cochran, Sep 30, 2004
    #2
    1. Advertising

  3. Hermes

    Jeff Dillon Guest

    You are setting objects to nothing only in one half of your subsequent IF
    statement

    Jeff
    "Hermes" <> wrote in message
    news:cjhlvd$qel$...
    > Hi all,
    >
    > We have a web page which validates users againt active directory (kinda),
    > Effectively the code we use will check the user's password and if

    successful
    > creates some session's for what access they have in the internal site. We
    > have noticed though that the query against the LDAP doesnt seem to
    > disconnect and by doing a netstat -a we get alot of ports with an
    > ESTABLISHED status on the LDAP server. When this gets to around 200 it

    goes
    > verrrrrrrrrrrrryyyyyyyyy slow on the site. If we do an unload on the IIS
    > they get released and goes back to normal speed.
    >
    > e.g.
    > TCP IISbox:4597 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4649 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4652 ldap.domainname.co.uk:ldap ESTABLISHED
    > TCP IISbox:4664 ldap.domainname.co.uk:ldap ESTABLISHED
    >
    > The following is the code,
    >
    > <%@ Language = VBScript %>
    > <%
    > on error resume next
    > Dim strADsPath
    > Dim strUserName
    > Dim strPassword
    > Dim iFlags
    > Dim strFullADsPath
    > Dim strFullUserName
    > Dim strADsNamespace
    > Dim oADsNamespace
    > Dim oADsObject
    > Session.Timeout=480
    > session("username") = request.form("username")
    > strADsPath = "DOMAIN-NAME"
    > strUserName = Request.Form("UserName")
    > strPassword = Request.Form("Password")
    > iFlags = "0"
    > strFullADsPath = "WinNT://"&strADsPath
    > strFullUserName = strADsPath&"\"&strUserName
    > Set oADsObject = GetObject(strFullADsPath)
    > strADsNamespace = left(strFullADsPath, instr(strFullADsPath, ":"))
    > set oADsNamespace = GetObject(strADsNamespace)
    > Set oADsObject = oADsNamespace.OpenDSObject(strFullADsPath,
    > strFullUserName, strPassword, 0)
    > if err.number = 0 then
    > Session("user_logged_in") = "true"
    > strUserName = session("username")
    > Set oUser = GetObject("WinNT://" & strADsPath & "/" & strUserName &
    > ",user")
    > GetUserFullName = oUser.FullName
    > if oGroup.Name = "Domain Admins" then
    > session("Group1") = "true"
    > session("Group2") = "true"
    > session("Group3") = "true"
    > end if
    > set strADsPath = nothing
    > set strUserName = nothing
    > set strPassword = nothing
    > set iFlags = nothing
    > set strFullADsPath = nothing
    > set strFullUserName = nothing
    > set strADsNamespace = nothing
    > set oADsNamespace = nothing
    > set oADsObject = nothing
    > Set oUser = nothing
    > else
    > Response.Redirect "denied_logout.asp"
    > end if
    > end if
    > %>
    >
    > Any comments or suggestions are gladly welcome :eek:)
    > Many thanks in advance,
    > Rob
    >
    >
     
    Jeff Dillon, Sep 30, 2004
    #3
  4. Hermes

    Hermes Guest

    Hi Jeff,

    Couldnt see the light for the light, it seems to of kinda worked, still
    getting them come up on the netstats but not as many now, so i'm going to go
    through the code on a few other pages which validates later on in the site.
    Do you know of anyway to close the connection other than setting them all
    the nothing?

    Cheers,
    Rob
    "Jeff Dillon" <> wrote in message
    news:%23P8V%...
    > You are setting objects to nothing only in one half of your subsequent IF
    > statement
    >
    > Jeff
    > "Hermes" <> wrote in message
    > news:cjhlvd$qel$...
    >> Hi all,
    >>
    >> We have a web page which validates users againt active directory (kinda),
    >> Effectively the code we use will check the user's password and if

    > successful
    >> creates some session's for what access they have in the internal site.
    >> We
    >> have noticed though that the query against the LDAP doesnt seem to
    >> disconnect and by doing a netstat -a we get alot of ports with an
    >> ESTABLISHED status on the LDAP server. When this gets to around 200 it

    > goes
    >> verrrrrrrrrrrrryyyyyyyyy slow on the site. If we do an unload on the IIS
    >> they get released and goes back to normal speed.
    >>
    >> e.g.
    >> TCP IISbox:4597 ldap.domainname.co.uk:ldap ESTABLISHED
    >> TCP IISbox:4649 ldap.domainname.co.uk:ldap ESTABLISHED
    >> TCP IISbox:4652 ldap.domainname.co.uk:ldap ESTABLISHED
    >> TCP IISbox:4664 ldap.domainname.co.uk:ldap ESTABLISHED
    >>
    >> The following is the code,
    >>
    >> <%@ Language = VBScript %>
    >> <%
    >> on error resume next
    >> Dim strADsPath
    >> Dim strUserName
    >> Dim strPassword
    >> Dim iFlags
    >> Dim strFullADsPath
    >> Dim strFullUserName
    >> Dim strADsNamespace
    >> Dim oADsNamespace
    >> Dim oADsObject
    >> Session.Timeout=480
    >> session("username") = request.form("username")
    >> strADsPath = "DOMAIN-NAME"
    >> strUserName = Request.Form("UserName")
    >> strPassword = Request.Form("Password")
    >> iFlags = "0"
    >> strFullADsPath = "WinNT://"&strADsPath
    >> strFullUserName = strADsPath&"\"&strUserName
    >> Set oADsObject = GetObject(strFullADsPath)
    >> strADsNamespace = left(strFullADsPath, instr(strFullADsPath, ":"))
    >> set oADsNamespace = GetObject(strADsNamespace)
    >> Set oADsObject = oADsNamespace.OpenDSObject(strFullADsPath,
    >> strFullUserName, strPassword, 0)
    >> if err.number = 0 then
    >> Session("user_logged_in") = "true"
    >> strUserName = session("username")
    >> Set oUser = GetObject("WinNT://" & strADsPath & "/" & strUserName &
    >> ",user")
    >> GetUserFullName = oUser.FullName
    >> if oGroup.Name = "Domain Admins" then
    >> session("Group1") = "true"
    >> session("Group2") = "true"
    >> session("Group3") = "true"
    >> end if
    >> set strADsPath = nothing
    >> set strUserName = nothing
    >> set strPassword = nothing
    >> set iFlags = nothing
    >> set strFullADsPath = nothing
    >> set strFullUserName = nothing
    >> set strADsNamespace = nothing
    >> set oADsNamespace = nothing
    >> set oADsObject = nothing
    >> Set oUser = nothing
    >> else
    >> Response.Redirect "denied_logout.asp"
    >> end if
    >> end if
    >> %>
    >>
    >> Any comments or suggestions are gladly welcome :eek:)
    >> Many thanks in advance,
    >> Rob
    >>
    >>

    >
    >
     
    Hermes, Oct 1, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael
    Replies:
    1
    Views:
    429
  2. Frank
    Replies:
    0
    Views:
    332
    Frank
    Aug 25, 2003
  3. Jamie
    Replies:
    2
    Views:
    1,074
  4. ejcosta
    Replies:
    2
    Views:
    884
    Eurico Costa
    Oct 8, 2004
  5. carlos seramos
    Replies:
    2
    Views:
    496
    carlos seramos
    Aug 1, 2003
Loading...

Share This Page