469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

ADSI

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
%>

Jul 19 '05 #1
6 4204
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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
%>

Jul 19 '05 #2
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" <sh*****@hotmail.com> wrote in message
news:#e*************@TK2MSFTNGP10.phx.gbl...
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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
%>


Jul 19 '05 #3
Is it possible to retrieve the email address as well

any help
"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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" <sh*****@hotmail.com> wrote in message
news:#e*************@TK2MSFTNGP10.phx.gbl...
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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
%>



Jul 19 '05 #4
http://www.15seconds.com/issue/020130.htm

That's the one I meant.

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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" <sh*****@hotmail.com> wrote in message
news:#e*************@TK2MSFTNGP10.phx.gbl...
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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
%>



Jul 19 '05 #5
This page
http://msdn.microsoft.com/library/de...i/iadsuser.asp
suggests a property called emailaddress
where do they get these crazy names.
"J P Singh" <noemail@asIhatespam> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Is it possible to retrieve the email address as well

any help
"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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" <sh*****@hotmail.com> wrote in message
news:#e*************@TK2MSFTNGP10.phx.gbl...
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
> 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
> %>
>
>
>



Jul 19 '05 #6
And this looks interesting..
http://www.4guysfromrolla.com/webtech/041800-1.shtml

"J P Singh" <noemail@asIhatespam> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Is it possible to retrieve the email address as well

any help
"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
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" <sh*****@hotmail.com> wrote in message
news:#e*************@TK2MSFTNGP10.phx.gbl...
http://www.15seconds.com/issue/011127.htm
refers to User.fullname under
"Changing User-Properties"

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
> 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
> %>
>
>
>



Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ryan Ritten | last post: by
2 posts views Thread by Enigma Webmaster | last post: by
14 posts views Thread by Arran Pearce | last post: by
3 posts views Thread by Roy Osherove | last post: by
8 posts views Thread by msnews.microsoft.com | last post: by
1 post views Thread by LittlePython | last post: by
8 posts views Thread by John | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.