Solved

Get NT account forename/surname via xp_cmdshell or similar

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.

856 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