473,473 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4412
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Akhlaq Khan | last post by:
we are developing an intranet application (web based) which needs to detect the logged in user ID of the user hitting the website. the intranet is huge and based on win2k active directory (around...
1
by: Ryan Ritten | last post by:
I was wondering if anyone knew how (or if it's even possible) to cache the results of an ADSI call in asp for a longer period of time. Basically what I am doing is I have a website that loads the...
2
by: Enigma Webmaster | last post by:
Hi All, We've written a couple of functions which, when run in VB6 work fine and allow AD users to be updated. When we include the code into an ASP Page and try and update a users information...
14
by: Arran Pearce | last post by:
Hi, I am looking for a way to use System.DirectoryServices to find all users on a domain whos accounts are either locked out or disabled. I have used ADSIEdit and the mmc schema add-in to try...
3
by: Roy Osherove | last post by:
Hi folks. I have an ASP.Net application that runs a .Net dll that uses WMI and ADSI(both managed) to connect to a given IIS root and search through it. When not using the ASP.Net client, but...
8
by: msnews.microsoft.com | last post by:
I have ADSI code that I can make work at the command line. I cannot in any way get it to work in asp.net. Even using Windows authentication, impersonation on, and providing the credentials...
3
by: chat_devil | last post by:
hi, does anyone know if it is possible to remove an attribute that can not be read into the ADSI property cache/collection. i'm trying to do an eDirectory password change from .net directory...
1
by: LittlePython | last post by:
I am a little confused on why I can not detect an object that does not exist with a try and except. If I understand ADSI correctly from what I have read you do not create these objects but rather...
8
by: John | last post by:
Hi, gurus, How can I implement the following feature in C#: Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group") For Each objMember In objGroup.Members...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.