Results 1 to 11 of 11
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validate user and go to ok page adsi ldap

    In asp classic no NET!

    Usign LDAP or ADSI

    i know:
    my server is server NT
    name of domain=dip
    name of group=my_group
    name of user=my_user

    With a input text box named "insert your userrname here"
    and a post button "verify"

    After pressign button, validate the user name if is present in the group, if YES goto my_ok_page.asp, if NO write an attention message in principal page.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: validate user and go to ok page adsi ldap

    Jerry

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: validate user and go to ok page adsi ldap

    Hi Jerry tks for link!
    But if i dont understand wrong the script refer to User and Password, i need to validate the User if esxistis in Group...:-(
    ... and i dont want to validate user in MDB access but in Winnt Nt Active Server....(LDAP or Adsi)

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: validate user and go to ok page adsi ldap

    You could search here: LDAP Forum @ Tek-Tips.

  5. #5
    New Lounger
    Join Date
    Jan 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: validate user and go to ok page adsi ldap

    This attachment should be a good start.
    It actually authenticates to AD for the username and password, and queries MS Access for user group membership. (At the moment.) The Access part is optional. (secondary security, non-AD grouping based websites [customer database], etc. )

    In your case, I am sure you could modify the AD query string to include the OU groups as you were looking to do. You can modify to divert code to different sites based on AD OU, instead of the Access method in the attachment. Please post the code if you are successful, I would be interested in implementing it. No time myself.

    Good luck!
    Attached Files Attached Files

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: validate user and go to ok page adsi ldap

    Hi friend...
    resolved 85% with the code here....but if i use the routine to assign to the var Susername the result of:

    Set objNetwork1 = CreateObject("WScript.Network")
    strUserDomain = objNetwork1.UserDomain
    sUserName = objNetwork1.UserName

    have error in
    Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")


    instead if i uset the sUserName = "OI24683" all work fine!!!
    Why?

    complete code:

    <html>

    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Nuova pagina 1</title>
    </head>

    <body>
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%

    Dim objNetwork1
    Dim SUserName
    sDomain = "DIP"

    Set objNetwork1 = CreateObject("WScript.Network")
    strUserDomain = objNetwork1.UserDomain
    sUserName = objNetwork1.UserName

    'sUserName = "OI24683"

    Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")

    For Each oGroup In oUser.Groups
    Select Case(oGroup.Name)
    Case "InpdapNAXX"
    'Response.write("InpdapNAXX")
    Response.Redirect("./default.html")
    Case "Group B"
    'response.write("Yay")
    Response.Redirect("A.asp")
    Case "Group C"
    response.Redirect("Z.asp")
    Case "Group D"
    Response.redirect("Y.asp")
    End Select
    Next
    %>

    </body>

    </html>
    </form>

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: validate user and go to ok page adsi ldap

    <P ID="edit" class=small>(Edited by jscher2000 on 13-Feb-08 21:08. )</P>
    <hr><code>Set objNetwork1 = CreateObject("WScript.Network")</code><hr>
    What value are you getting for UserName? Try adding a MsgBox(sUserName) to your page. If it's blank or invalid, then there might be a problem using this object from inside the browser.

    Edit: Wait a minute. That's ASP. That script is running on the server. Forget the MsgBox.

    If you are trying to retrieve information about the end user of the browser, that approach is not going to work.

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: validate user and go to ok page adsi ldap

    perpahs intercept error...
    In response.write have: IUSR_CL151F4500 (is the name of client) and not the username of logged user...
    Have idea?

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: validate user and go to ok page adsi ldap

    The prefix IUSR_ probably indicates the name created by the web server for the user. The server does not know the actual username, just the user's PC's IP address.

    I don't know how you can accurately retrieve the username. You can run your VBScript in IE on the browser side and embed it into hidden fields and have the user submit that form to the server. But form data can be forged, so if security is essential, that is not a great solution.

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: validate user and go to ok page adsi ldap

    <big>Sal, I have asked you before NOT to use <!t>[script]<!/t> and <!t>[/script]<!/t> tags for code. It makes the text unreadable! I have removed them - HansV</big>

    Hi perpah resolved with the code here...
    The code return the really username of user...(OI24683 is my username) in a msgbox, and that is just i want!

    <html>

    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Nuova pagina 1</title>
    </head>
    <body>

    <script language="vbscript">

    Dim strUserName
    Set WSHNetwork = CreateObject("WScript.Network")
    strUserName = WSHNetwork.UserName
    MsgBox (strUserName)

    </script>

    </body>
    </html>

    now is possible to integrate the code above with the first code and pass the value of strUserName in var sUserName similar
    sUserName = strUserName ...

    <html>

    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Nuova pagina 1</title>
    </head>

    <body>
    <%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
    <%
    'test_ldap_USER_IN_GROUP_OK.asp
    Dim strUserName
    Dim sDomain

    sDomain = &quot;DIP&quot;
    sUserName = &quot;OI24683&quot;

    Set oUser = GetObject(&quot;WinNT://&quot; & sDomain & &quot;/&quot; & sUserName & &quot;,user&quot

    For Each oGroup In oUser.Groups
    Select Case(oGroup.Name)
    Case &quot;InpdapNAXX&quot;
    'Response.write(&quot;InpdapNAXX&quot
    Response.Redirect(&quot;./default.html&quot
    Case &quot;Group B&quot;
    'response.write(&quot;Yay&quot
    Response.Redirect(&quot;A.asp&quot
    Case &quot;Group C&quot;
    'response.Redirect(&quot;Z.asp&quot
    Case &quot;Group D&quot;
    'Response.redirect(&quot;Y.asp&quot
    Case else
    Response.Redirect(&quot;./non_autenticato.html&quot
    End Select
    Next
    %>

    </body>

    </html>
    </form>

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: validate user and go to ok page adsi ldap

    <P ID="edit" class=small>(Edited by jscher2000 on 16-Feb-08 08:32. )</P>Not sure, but you might be able to find code that fits in as described below:

    <code><body>
    <form name="checkUser" action="your_page.asp" method="post">
    <input type="hidden" name="sUserName" value="TBD">
    </form>


    <script language="vbscript">
    Dim strUserName
    Set WSHNetwork = CreateObject("WScript.Network")
    strUserName = WSHNetwork.UserName
    document.all.sUserName.value = strUserName 'Not sure this is the correct code
    document.all.checkUser.submit() ' Not sure this is the correct code
    </script></code>

    Added:

    Notes:

    (1) Perhaps it is better to have the user press Submit. You could add a submit button to the form instead of having the script submit the form.

    (2) On the .asp page side, retrieve the value of sUserName using Request.Form("sUserName")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •