Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

'user_name()' funtion  returns domain as well

Posted on 2003-11-21
3
Medium Priority
?
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
Joeharvey earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

715 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