Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

'user_name()' funtion returns domain as well

I have set of logins and users for a database who all inherit permissions from a Windows group.

When a user takes a record, a field called '[UName]' is populated.  I have set the default value of this field to the function  'user_name()' to get the value into the field.

I do not want any of the logins, database access permissions of their own as they automatically inherit from the Windows Group.  However if I take all db permissions away and rely on the group permissions, 'user_name()' returns 'mydomain/harry' instead of just 'harry'.

I would like to return just the username without the domain.  Is there another command that will do this for me or will I have to resort to string manipulation?

Wing
0
WingYip
Asked:
WingYip
1 Solution
 
JoeharveyCommented:
user_name() gets the information straight from the SYSUSERS table.  If the account is an NT authenticated account, it will always have the domain prefix on it.  You will need to modify the string yourself.

jm
0
 
arbertCommented:
Also, take a look at User_Name() or system_user
0
 
WingYipAuthor Commented:
Thanks all

Wing
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now