Helpful Information
 
 
Category: LDAP Programming
Search for a user in Active Directory

I have a logon script in VB that I use in a Windows 2000 AD native mode environment. I would like to have an LDAP search for the logged on user, and return a record set, so that I may append information in the "description" field on the user account.

I have been unsuccesful in creating a search that works.

Has anyone accomplished this task, and if so, would you be willing to shed some light?

Thanks,

you can not retrieve the logged on user from AD. AD contains the clients (workstations), but not who the individual is that is logged onto it. You have to query the workstation to find that out.

'==================FUNCTION==================
'Name/Params: getLoggedOnUser(pcname)
'Purpose: Connect to computer, grab currently logged on user and return value
'==============================================
function getLoggedOnUser(pcname)
on error resume next
set objWMI = GetObject("winmgmts:\\" & pcname & "\root\cimv2:win32_computersystem")

if err.number = 0 then
set results = objWMI.Instances_
for each obj in results
getLoggedOnUser = obj.username
next
end if
err.clear
end function










privacy (GDPR)