Solved

'user_name()' funtion  returns domain as well

Posted on 2003-11-21
3
309 Views
Last Modified: 2012-08-14
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
Comment
Question by:WingYip
3 Comments
 
LVL 3

Accepted Solution

by:
Joeharvey earned 50 total points
ID: 9796420
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
 
LVL 34

Expert Comment

by:arbert
ID: 9797126
Also, take a look at User_Name() or system_user
0
 
LVL 1

Author Comment

by:WingYip
ID: 9798558
Thanks all

Wing
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

830 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