GrahamAtJobserve
asked on
Get current User, using ADSI
A simple question this one. All I need to do is to get the current NT user, using Active Directory Service.
ASKER
I wish to get the name of the current user, on the machine the app is running on.
NOT using the API. I've got this function already, but trying to 'upgrade' to ADSI. The upgrade is seeming like a retrograde step at present. Its slower than before.
Tried the code - won't compile. What references does it need to run?
NOT using the API. I've got this function already, but trying to 'upgrade' to ADSI. The upgrade is seeming like a retrograde step at present. Its slower than before.
Tried the code - won't compile. What references does it need to run?
ASKER
I have the references, I think. I'm getting the intellisense functions appear, and its in the object browser, but getting the '429 - activex component cant create object' messgae
Have you selected the reference: Active DS Type Library?
Should be in C:\WinNT\System32\activeds .tlb
When you run the app is it on a dev machine? or a prod machine. Because if you don;t install the activeds.tlb on the client, then you will get the ActiveX 429 error
Should be in C:\WinNT\System32\activeds
When you run the app is it on a dev machine? or a prod machine. Because if you don;t install the activeds.tlb on the client, then you will get the ActiveX 429 error
ASKER
Yes, its selected, and working on my own PC in dev. I'm getting other ADSI functions to work, eg lists of groups, users etc, I just can't get who the current user is.
Are you running version 2.5 of ADSI?
Also what is your dev machine and the client OS?
If client is NT4 try this:
Dim ntsys As New WinNTSystemInfo
Debug.print "User: " & ntsys.UserName
Debug.print "Computer: " & ntsys.ComputerName
Debug.print "Domain: " & ntsys.DomainName
Debug.print "PDC: " & ntsys.PDC
But ActiveX 429 is usually the fact that you do not have the correct COM object int his case the Activeds.tlb on the computer.
Also what is your dev machine and the client OS?
If client is NT4 try this:
Dim ntsys As New WinNTSystemInfo
Debug.print "User: " & ntsys.UserName
Debug.print "Computer: " & ntsys.ComputerName
Debug.print "Domain: " & ntsys.DomainName
Debug.print "PDC: " & ntsys.PDC
But ActiveX 429 is usually the fact that you do not have the correct COM object int his case the Activeds.tlb on the computer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thats perfect, exactly what I needed.
Thaknk you.
Thaknk you.
Well below is simple code to get the local computer users name (Of course you could just use the Win32 API GetUserName)
Dim sys As New ADSystemInfo
Debug.print "User: " & sys.UserName
Debug.print "Computer: " & sys.ComputerName
Debug.print "Domain: " & sys.DomainDNSName
Debug.print "PDC Role Owner: " & sys.PDCRoleOwner