ADSI

Discussion in 'ASP General' started by Miguel Orrego, Sep 10, 2003.

  1. Hi,

    I have found some code that authenticates users agains a domain using ADSI.
    I then redirect to another page and pass the username they have entered as a
    string. However, it would be nice to also get their full name from Active
    Directory once authenticated. Can anyone suggest how I may modify this code
    to achieve this? I would also like to pass their full name to the next page
    as a string. The code I found:

    <%

    if (not strADsPath= "") then

    ' bind to the ADSI object. If user has supplied a username, then
    ' authenticate too
    strADsPath = "WinNT://" & strADsPath
    Dim oADsObject
    Dim tempstr
    tempstr = strDomain & "\" & strUserName


    Set oADsObject = GetObject(strADsPath)


    Dim strADsNamespace
    Dim oADsNamespace
    strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    set oADsNamespace = GetObject(strADsNamespace)

    Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    strPassword, 0)

    ' we've only managed to bind if err.number = 0
    if not (Err.number = 0) then
    Response.Write "Login Failed, please try again</strong><br>"

    else
    'If the password is correct then set the session variable to True
    Session("blnIsUserGood") = True

    'Close Objects before redirecting
    Set adoCon = Nothing
    Set strCon = Nothing
    Set rsCheckUser = Nothing

    'Redirect to the authorised user page and send the users name

    response.redirect "success.asp?username="&strUserName
    %>
    Miguel Orrego, Sep 10, 2003
    #1
    1. Advertising

  2. Miguel Orrego

    Tom B Guest

    http://www.15seconds.com/issue/011127.htm
    refers to User.fullname under
    "Changing User-Properties"

    "Miguel Orrego" <-nospam> wrote in message
    news:3f5f3825$0$253$...
    > Hi,
    >
    > I have found some code that authenticates users agains a domain using

    ADSI.
    > I then redirect to another page and pass the username they have entered as

    a
    > string. However, it would be nice to also get their full name from Active
    > Directory once authenticated. Can anyone suggest how I may modify this

    code
    > to achieve this? I would also like to pass their full name to the next

    page
    > as a string. The code I found:
    >
    > <%
    >
    > if (not strADsPath= "") then
    >
    > ' bind to the ADSI object. If user has supplied a username, then
    > ' authenticate too
    > strADsPath = "WinNT://" & strADsPath
    > Dim oADsObject
    > Dim tempstr
    > tempstr = strDomain & "\" & strUserName
    >
    >
    > Set oADsObject = GetObject(strADsPath)
    >
    >
    > Dim strADsNamespace
    > Dim oADsNamespace
    > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > set oADsNamespace = GetObject(strADsNamespace)
    >
    > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > strPassword, 0)
    >
    > ' we've only managed to bind if err.number = 0
    > if not (Err.number = 0) then
    > Response.Write "Login Failed, please try again</strong><br>"
    >
    > else
    > 'If the password is correct then set the session variable to True
    > Session("blnIsUserGood") = True
    >
    > 'Close Objects before redirecting
    > Set adoCon = Nothing
    > Set strCon = Nothing
    > Set rsCheckUser = Nothing
    >
    > 'Redirect to the authorised user page and send the users name
    >
    > response.redirect "success.asp?username="&strUserName
    > %>
    >
    >
    >
    Tom B, Sep 10, 2003
    #2
    1. Advertising

  3. Thanks Tom,

    After checking that article I added the following code and it works a treat.
    Thanks again.

    Dim FullName
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUserName & ",user")
    FullName = User.Fullname


    "Tom B" <> wrote in message
    news:#...
    > http://www.15seconds.com/issue/011127.htm
    > refers to User.fullname under
    > "Changing User-Properties"
    >
    > "Miguel Orrego" <-nospam> wrote in message
    > news:3f5f3825$0$253$...
    > > Hi,
    > >
    > > I have found some code that authenticates users agains a domain using

    > ADSI.
    > > I then redirect to another page and pass the username they have entered

    as
    > a
    > > string. However, it would be nice to also get their full name from

    Active
    > > Directory once authenticated. Can anyone suggest how I may modify this

    > code
    > > to achieve this? I would also like to pass their full name to the next

    > page
    > > as a string. The code I found:
    > >
    > > <%
    > >
    > > if (not strADsPath= "") then
    > >
    > > ' bind to the ADSI object. If user has supplied a username, then
    > > ' authenticate too
    > > strADsPath = "WinNT://" & strADsPath
    > > Dim oADsObject
    > > Dim tempstr
    > > tempstr = strDomain & "\" & strUserName
    > >
    > >
    > > Set oADsObject = GetObject(strADsPath)
    > >
    > >
    > > Dim strADsNamespace
    > > Dim oADsNamespace
    > > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > > set oADsNamespace = GetObject(strADsNamespace)
    > >
    > > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > > strPassword, 0)
    > >
    > > ' we've only managed to bind if err.number = 0
    > > if not (Err.number = 0) then
    > > Response.Write "Login Failed, please try again</strong><br>"
    > >
    > > else
    > > 'If the password is correct then set the session variable to True
    > > Session("blnIsUserGood") = True
    > >
    > > 'Close Objects before redirecting
    > > Set adoCon = Nothing
    > > Set strCon = Nothing
    > > Set rsCheckUser = Nothing
    > >
    > > 'Redirect to the authorised user page and send the users name
    > >
    > > response.redirect "success.asp?username="&strUserName
    > > %>
    > >
    > >
    > >

    >
    >
    Miguel Orrego, Sep 10, 2003
    #3
  4. Miguel Orrego

    J P Singh Guest

    Re: ADSI - Is it possible to retrieve email address

    Is it possible to retrieve the email address as well

    any help


    "Miguel Orrego" <-nospam> wrote in message
    news:3f5f41df$0$248$...
    > Thanks Tom,
    >
    > After checking that article I added the following code and it works a

    treat.
    > Thanks again.
    >
    > Dim FullName
    > Dim User
    > Set User = GetObject("WinNT://" & strDomain & "/" & strUserName &

    ",user")
    > FullName = User.Fullname
    >
    >
    > "Tom B" <> wrote in message
    > news:#...
    > > http://www.15seconds.com/issue/011127.htm
    > > refers to User.fullname under
    > > "Changing User-Properties"
    > >
    > > "Miguel Orrego" <-nospam> wrote in message
    > > news:3f5f3825$0$253$...
    > > > Hi,
    > > >
    > > > I have found some code that authenticates users agains a domain using

    > > ADSI.
    > > > I then redirect to another page and pass the username they have

    entered
    > as
    > > a
    > > > string. However, it would be nice to also get their full name from

    > Active
    > > > Directory once authenticated. Can anyone suggest how I may modify this

    > > code
    > > > to achieve this? I would also like to pass their full name to the next

    > > page
    > > > as a string. The code I found:
    > > >
    > > > <%
    > > >
    > > > if (not strADsPath= "") then
    > > >
    > > > ' bind to the ADSI object. If user has supplied a username, then
    > > > ' authenticate too
    > > > strADsPath = "WinNT://" & strADsPath
    > > > Dim oADsObject
    > > > Dim tempstr
    > > > tempstr = strDomain & "\" & strUserName
    > > >
    > > >
    > > > Set oADsObject = GetObject(strADsPath)
    > > >
    > > >
    > > > Dim strADsNamespace
    > > > Dim oADsNamespace
    > > > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > > > set oADsNamespace = GetObject(strADsNamespace)
    > > >
    > > > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > > > strPassword, 0)
    > > >
    > > > ' we've only managed to bind if err.number = 0
    > > > if not (Err.number = 0) then
    > > > Response.Write "Login Failed, please try again</strong><br>"
    > > >
    > > > else
    > > > 'If the password is correct then set the session variable to True
    > > > Session("blnIsUserGood") = True
    > > >
    > > > 'Close Objects before redirecting
    > > > Set adoCon = Nothing
    > > > Set strCon = Nothing
    > > > Set rsCheckUser = Nothing
    > > >
    > > > 'Redirect to the authorised user page and send the users name
    > > >
    > > > response.redirect "success.asp?username="&strUserName
    > > > %>
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    J P Singh, Sep 10, 2003
    #4
  5. Miguel Orrego

    Tom B Guest

    http://www.15seconds.com/issue/020130.htm

    That's the one I meant.

    "Miguel Orrego" <-nospam> wrote in message
    news:3f5f41df$0$248$...
    > Thanks Tom,
    >
    > After checking that article I added the following code and it works a

    treat.
    > Thanks again.
    >
    > Dim FullName
    > Dim User
    > Set User = GetObject("WinNT://" & strDomain & "/" & strUserName &

    ",user")
    > FullName = User.Fullname
    >
    >
    > "Tom B" <> wrote in message
    > news:#...
    > > http://www.15seconds.com/issue/011127.htm
    > > refers to User.fullname under
    > > "Changing User-Properties"
    > >
    > > "Miguel Orrego" <-nospam> wrote in message
    > > news:3f5f3825$0$253$...
    > > > Hi,
    > > >
    > > > I have found some code that authenticates users agains a domain using

    > > ADSI.
    > > > I then redirect to another page and pass the username they have

    entered
    > as
    > > a
    > > > string. However, it would be nice to also get their full name from

    > Active
    > > > Directory once authenticated. Can anyone suggest how I may modify this

    > > code
    > > > to achieve this? I would also like to pass their full name to the next

    > > page
    > > > as a string. The code I found:
    > > >
    > > > <%
    > > >
    > > > if (not strADsPath= "") then
    > > >
    > > > ' bind to the ADSI object. If user has supplied a username, then
    > > > ' authenticate too
    > > > strADsPath = "WinNT://" & strADsPath
    > > > Dim oADsObject
    > > > Dim tempstr
    > > > tempstr = strDomain & "\" & strUserName
    > > >
    > > >
    > > > Set oADsObject = GetObject(strADsPath)
    > > >
    > > >
    > > > Dim strADsNamespace
    > > > Dim oADsNamespace
    > > > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > > > set oADsNamespace = GetObject(strADsNamespace)
    > > >
    > > > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > > > strPassword, 0)
    > > >
    > > > ' we've only managed to bind if err.number = 0
    > > > if not (Err.number = 0) then
    > > > Response.Write "Login Failed, please try again</strong><br>"
    > > >
    > > > else
    > > > 'If the password is correct then set the session variable to True
    > > > Session("blnIsUserGood") = True
    > > >
    > > > 'Close Objects before redirecting
    > > > Set adoCon = Nothing
    > > > Set strCon = Nothing
    > > > Set rsCheckUser = Nothing
    > > >
    > > > 'Redirect to the authorised user page and send the users name
    > > >
    > > > response.redirect "success.asp?username="&strUserName
    > > > %>
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Tom B, Sep 10, 2003
    #5
  6. Miguel Orrego

    Tom B Guest

    Re: ADSI - Is it possible to retrieve email address

    This page
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/iadsuser.asp
    suggests a property called emailaddress
    where do they get these crazy names.
    "J P Singh" <noemail@asIhatespam> wrote in message
    news:...
    > Is it possible to retrieve the email address as well
    >
    > any help
    >
    >
    > "Miguel Orrego" <-nospam> wrote in message
    > news:3f5f41df$0$248$...
    > > Thanks Tom,
    > >
    > > After checking that article I added the following code and it works a

    > treat.
    > > Thanks again.
    > >
    > > Dim FullName
    > > Dim User
    > > Set User = GetObject("WinNT://" & strDomain & "/" & strUserName &

    > ",user")
    > > FullName = User.Fullname
    > >
    > >
    > > "Tom B" <> wrote in message
    > > news:#...
    > > > http://www.15seconds.com/issue/011127.htm
    > > > refers to User.fullname under
    > > > "Changing User-Properties"
    > > >
    > > > "Miguel Orrego" <-nospam> wrote in message
    > > > news:3f5f3825$0$253$...
    > > > > Hi,
    > > > >
    > > > > I have found some code that authenticates users agains a domain

    using
    > > > ADSI.
    > > > > I then redirect to another page and pass the username they have

    > entered
    > > as
    > > > a
    > > > > string. However, it would be nice to also get their full name from

    > > Active
    > > > > Directory once authenticated. Can anyone suggest how I may modify

    this
    > > > code
    > > > > to achieve this? I would also like to pass their full name to the

    next
    > > > page
    > > > > as a string. The code I found:
    > > > >
    > > > > <%
    > > > >
    > > > > if (not strADsPath= "") then
    > > > >
    > > > > ' bind to the ADSI object. If user has supplied a username, then
    > > > > ' authenticate too
    > > > > strADsPath = "WinNT://" & strADsPath
    > > > > Dim oADsObject
    > > > > Dim tempstr
    > > > > tempstr = strDomain & "\" & strUserName
    > > > >
    > > > >
    > > > > Set oADsObject = GetObject(strADsPath)
    > > > >
    > > > >
    > > > > Dim strADsNamespace
    > > > > Dim oADsNamespace
    > > > > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > > > > set oADsNamespace = GetObject(strADsNamespace)
    > > > >
    > > > > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > > > > strPassword, 0)
    > > > >
    > > > > ' we've only managed to bind if err.number = 0
    > > > > if not (Err.number = 0) then
    > > > > Response.Write "Login Failed, please try again</strong><br>"
    > > > >
    > > > > else
    > > > > 'If the password is correct then set the session variable to True
    > > > > Session("blnIsUserGood") = True
    > > > >
    > > > > 'Close Objects before redirecting
    > > > > Set adoCon = Nothing
    > > > > Set strCon = Nothing
    > > > > Set rsCheckUser = Nothing
    > > > >
    > > > > 'Redirect to the authorised user page and send the users name
    > > > >
    > > > > response.redirect "success.asp?username="&strUserName
    > > > > %>
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Tom B, Sep 10, 2003
    #6
  7. Miguel Orrego

    Tom B Guest

    Re: ADSI - Is it possible to retrieve email address

    And this looks interesting..
    http://www.4guysfromrolla.com/webtech/041800-1.shtml

    "J P Singh" <noemail@asIhatespam> wrote in message
    news:...
    > Is it possible to retrieve the email address as well
    >
    > any help
    >
    >
    > "Miguel Orrego" <-nospam> wrote in message
    > news:3f5f41df$0$248$...
    > > Thanks Tom,
    > >
    > > After checking that article I added the following code and it works a

    > treat.
    > > Thanks again.
    > >
    > > Dim FullName
    > > Dim User
    > > Set User = GetObject("WinNT://" & strDomain & "/" & strUserName &

    > ",user")
    > > FullName = User.Fullname
    > >
    > >
    > > "Tom B" <> wrote in message
    > > news:#...
    > > > http://www.15seconds.com/issue/011127.htm
    > > > refers to User.fullname under
    > > > "Changing User-Properties"
    > > >
    > > > "Miguel Orrego" <-nospam> wrote in message
    > > > news:3f5f3825$0$253$...
    > > > > Hi,
    > > > >
    > > > > I have found some code that authenticates users agains a domain

    using
    > > > ADSI.
    > > > > I then redirect to another page and pass the username they have

    > entered
    > > as
    > > > a
    > > > > string. However, it would be nice to also get their full name from

    > > Active
    > > > > Directory once authenticated. Can anyone suggest how I may modify

    this
    > > > code
    > > > > to achieve this? I would also like to pass their full name to the

    next
    > > > page
    > > > > as a string. The code I found:
    > > > >
    > > > > <%
    > > > >
    > > > > if (not strADsPath= "") then
    > > > >
    > > > > ' bind to the ADSI object. If user has supplied a username, then
    > > > > ' authenticate too
    > > > > strADsPath = "WinNT://" & strADsPath
    > > > > Dim oADsObject
    > > > > Dim tempstr
    > > > > tempstr = strDomain & "\" & strUserName
    > > > >
    > > > >
    > > > > Set oADsObject = GetObject(strADsPath)
    > > > >
    > > > >
    > > > > Dim strADsNamespace
    > > > > Dim oADsNamespace
    > > > > strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
    > > > > set oADsNamespace = GetObject(strADsNamespace)
    > > > >
    > > > > Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr,
    > > > > strPassword, 0)
    > > > >
    > > > > ' we've only managed to bind if err.number = 0
    > > > > if not (Err.number = 0) then
    > > > > Response.Write "Login Failed, please try again</strong><br>"
    > > > >
    > > > > else
    > > > > 'If the password is correct then set the session variable to True
    > > > > Session("blnIsUserGood") = True
    > > > >
    > > > > 'Close Objects before redirecting
    > > > > Set adoCon = Nothing
    > > > > Set strCon = Nothing
    > > > > Set rsCheckUser = Nothing
    > > > >
    > > > > 'Redirect to the authorised user page and send the users name
    > > > >
    > > > > response.redirect "success.asp?username="&strUserName
    > > > > %>
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Tom B, Sep 10, 2003
    #7
    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. Justin Rich

    ADSI - Syntax for msExchTurfListNames

    Justin Rich, Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    957
    Justin Rich
    Jun 26, 2003
  2. khaja shaik

    ADSI/LDAP Query

    khaja shaik, Jul 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    610
    khaja shaik
    Jul 21, 2003
  3. Roy Osherove

    Access Denied for WMI/ADSI over ASP.Net

    Roy Osherove, Sep 9, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    7,116
    s.becker
    Sep 14, 2003
  4. venkat

    Retrieve logon user name from ADSI

    venkat, Nov 6, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    457
    venkat
    Nov 6, 2003
  5. shiv

    ADSI - User A/c Info Question

    shiv, Nov 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    342
    Natty Gur
    Nov 16, 2003
Loading...

Share This Page