Fullname of current user

L

Leszek

Hello!

I have my webpage (ASP) in domain (IIS 6.0).
I need to make a popup with fullname of current user.
How can I do this?
Maybe someone have any examples?

Thanks!
 
J

James Jones

by current user, do you mean you want the current user of the user account
on windows, or you want the full name of the current user browsing your
website?
 
L

Leszek

I want the fullname of the user browsing this page.
IIS is set to Windows Authentication.

BTW. In 99,99% both accounts (for login to Windows and for browsing page)
Will be the same.
 
S

Slim

not easy.

do you have any expirance in COM+?

if so i have made a COM+ component that wil do the job, it will also let
your users change passwords from the internet.

code is below , make sure you change this line to suit your domain

"SELECT distinguishedName FROM 'LDAP://dc=yourdomain,dc=local'

you will need to save this code in VB as a activeX dll, the register it in
component services,

then call it in your asp page like this

dim dUser
dUser = Request.ServerVariables("REMOTE_USER")
dim ADSI
Set ADSI = Server.CreateObject("ADSI.User")
Response.Write ADSI.getFullName( CStr( dUser))




Function getFullName(userName As String) As String
On Error Resume Next
Dim oUser: Set oUser = GetObject("LDAP://" & getUserDN(CStr(userName)))
getFullName = oUser.FullName
End Function

Function changePassword(userName As String, existingPassword As String,
newPassword As String) As Boolean
On Error Resume Next
Dim oUser: Set oUser = GetObject("LDAP://" & getUserDN(CStr(userName)))
oUser.changePassword existingPassword, newPassword
oUser.SetInfo
If Err.Number = 0 Then
changePassword = True
Else
changePassword = False
End If
End Function


Function getUserDN(userName As String) As String
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 10
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=yourdomain,dc=local' WHERE
objectCategory='user' " & _
"AND sAMAccountName='" & userName & "'"
Set objRecordSet = objCommand.Execute
Dim ans
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
ans = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
getUserDN = ans
End Function
 
L

Leszek

I made it other way, but thanks for help!

sub br()
Response.Write("<br/>")
end sub
sub prln(text)
pr(text)
' br()
end sub

dim GLOBAL_redirect
dim usrTab
Dim CONTAINER
Dim domain, user
Dim objConnection, objComman, objRecordSet
Dim lewo, prawo, czesc
Const ADS_SCOPE_SUBTREE = 2

redirect=false
set userFull = Request.ServerVariables("LOGON_USER")

usrTab = Split(userFull,"\")
Set obj = CreateObject("WScript.Network")
domain = usrTab(0)
user = usrTab(1)
CONTAINER = "dc=" & domain & ",dc=pl"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select distinguishedName from " & "'LDAP://" &
CONTAINER & "' where objectClass='user' AND samAccountName='" & user & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
if not objRecordSet.EOF then
else
end if

lewo = objrecordset.Fields("distinguishedName").Value
Dim tablica1, tablica2
tablica1 = Split(lewo, ",")
tablica2 = Split(CStr(tablica1(0)), "=")
prln(tablica2(1))
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top