Get NT account forename/surname via xp_cmdshell or similar
Posted on 2009-07-10
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 firstname.lastname@example.org - 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.