Solved

Get NT account forename/surname via xp_cmdshell or similar

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Users of Windows 10 Professional can disable automatic reboots using the policy editor. This tool is not included in the Windows home edition. But don't worry! Follow the instructions below to install (a Win7) policy editor on your Windows 10 Home e…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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