Solved

Get NT account forename/surname via xp_cmdshell or similar

Posted on 2009-07-10
2
436 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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