Solved

Get current User, using ADSI

Posted on 2002-07-23
8
613 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
ID: 7171367
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
ID: 7171375
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
ID: 7171387
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 5

Expert Comment

by:RainUK
ID: 7171422
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
 

Author Comment

by:GrahamAtJobserve
ID: 7171430
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
ID: 7171441
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
ID: 7171442
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
ID: 7171454
Thats perfect, exactly what I needed.

Thaknk you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

816 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

10 Experts available now in Live!

Get 1:1 Help Now