ADSI

M

Miguel Orrego

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

Miguel Orrego

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top