Solved

Get current User, using ADSI

Posted on 2002-07-23
8
611 Views
Last Modified: 2007-11-27
A simple question this one. All I need to do is to get the current NT user, using Active Directory Service.

0
Comment
Question by:GrahamAtJobserve
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:RainUK
Comment Utility
Do you wish to get the name of the user on the machine the app is running on or on another computer across the network?

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
0
 

Author Comment

by:GrahamAtJobserve
Comment Utility
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?
0
 

Author Comment

by:GrahamAtJobserve
Comment Utility
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
0
 
LVL 5

Expert Comment

by:RainUK
Comment Utility
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

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:GrahamAtJobserve
Comment Utility
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.


0
 
LVL 5

Expert Comment

by:RainUK
Comment Utility
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.
0
 
LVL 5

Accepted Solution

by:
RainUK earned 100 total points
Comment Utility
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.
0
 

Author Comment

by:GrahamAtJobserve
Comment Utility
Thats perfect, exactly what I needed.

Thaknk you.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now