Jump to content
Sign in to follow this  
natetron66

Need help with grabbing user name

Recommended Posts

natetron66

Hi, I'm having a little trouble grabbing a user name. I have a script currently that grabs OS, RAM, Hard Drive, etc for invenotry that runs as a startup script and saves to sql. Currently I grab the user name, which all of our employee numbers are there user name. Example: 16830 is the user name I'm getting. However, I want to get there actual Employee Name. In Active Directory, for each user, there Display name is their full name. In Windows, when I click start, it says log off "John Doe" so the Display name is being passed with each user name.

So, based on that. I need assistance obtaining the Display Name from Active Directory, based on the username of the currently logged in user. Thanks ahead of time for your help!

Share this post


Link to post
Share on other sites
Valuater

@UserName ?

8)

BTW.... Welcome to the Autoit Forums... 8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
natetron66

@UserName ?

8)

BTW.... Welcome to the Autoit Forums... 8)

I am using @username to grab the user name. Yes that is working. User name is returning as 16830, which is the employee #. But I also want to grab their FULL NAME which is the Display Name in Active Directory.

Share this post


Link to post
Share on other sites
DaRam

Check out

%windir%\System32\rundll32.exe dsquery,OpenQueryWindow

Share this post


Link to post
Share on other sites
natetron66

Check out

%windir%\System32\rundll32.exe dsquery,OpenQueryWindow

How's that help?

Share this post


Link to post
Share on other sites
natetron66

Yes I did try that. And I used this usage of it:

dsquery user -samid %username%

and it returns what I'm looking for.

So now, I just have to have that command run within AutoIt, any help with running that dos command in autoit daram??

Share this post


Link to post
Share on other sites
Zombie1982

Yes I did try that. And I used this usage of it:

dsquery user -samid %username%

and it returns what I'm looking for.

So now, I just have to have that command run within AutoIt, any help with running that dos command in autoit daram??

Run or ShellExecute, mayhap? I dont quite know much more to suggest myself.

Luckily there are much smarter people than me hanging around here. :D

Share this post


Link to post
Share on other sites
natetron66

Run or ShellExecute, mayhap? I dont quite know much more to suggest myself.

Luckily there are much smarter people than me hanging around here. :D

Tried that. And I keep getting an error saying error in dsquery. Missing entry:user.

The same command runs fine from command line, but when using shellexecute i get this error. HELP! Need o get this done today. Thanks guys!

Share this post


Link to post
Share on other sites
weaponx

Here you go:

#570726

Share this post


Link to post
Share on other sites
natetron66

Here you go:

#570726

Dude thanks so much!!! Exactly what I was looking for!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×