Solved

Get NT account forename/surname via xp_cmdshell or similar

Posted on 2009-07-10
2
395 Views
Last Modified: 2012-05-07
I currently have a list of users in a windows group in a table - gained by using

      create table tempdb.dbo.GroupMembers(ACCOUNT_NAME nVARCHAR(128),account_type varchar(10),account_priv varchar(10),account_mapped_login_name varchar(50),account_permission_path varchar(50))

      INSERT INTO tempdb.dbo.GroupMembers
      exec XP_LOGININFO groupname,'Members'

I need to send out an email to each user - email uses a stanrd format forename.surname@company.com - but have noticed there are no standard naming conventions to the NT accounts - so I can derive the email address from the account name.

Does anyone know how I can get the surname/forenames from the NT account? I will be able to use XP_CMDSHELL or anything else. Security will be opened up to allow any type of functionality that will work - so this will not be an issue. I guess I am asking if there is an API I can call.

Many thanks.
0
Comment
Question by:PUMASOFT
2 Comments
 
LVL 12

Accepted Solution

by:
kevin_u earned 500 total points
ID: 24825042
The link below is the source for userinfo.vbs which can get almost any user information you'd like.  Read it over, and modify it to get the informtion you need.   Then call it with xp_cmdshell as indicated in the comments (cscript).

http://www.ss64.com/wsh/userinfo.txt

0
 
LVL 2

Author Comment

by:PUMASOFT
ID: 24825129
Mmmm - might have a look at that. I will be on holiday next week. So will update week after.

Many thanks.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In today's information driven age, entrepreneurs have so many great tools and options at their disposal to help turn good ideas into a thriving business. With cloud-based online services, such as Amazon's Web Services (AWS) or Microsoft's Azure, bus…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

22 Experts available now in Live!

Get 1:1 Help Now