Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When I'm try to get current logged user name for account domain\username and I added many users to this option "Account operates as System" In code I got the system account not the real name of user "Domain\username" and i want the real name and real Id for this used to difference between users all of them are with option "Account operates as System" The code I used :

SPContext.Current.Web.CurrentUser.Name;

Thanks

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You can try this if I understand you correct?

Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.LoginName;

or

HttpContext.Current.User.Identity.Name

and

Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.ID;

hope this helps :)

share|improve this answer
    
its give me the name ok but how to get the id of this user –  FarOoOosa Aug 14 '12 at 10:13
    
iv just changed the post, lol forgot to add the ID part ;) –  ali Sharepoint Aug 14 '12 at 10:16
    
SPContext.Current.Web.CurrentUser.ID or .Name not works for me that what I was use –  FarOoOosa Aug 14 '12 at 10:37
    
HttpContext.Current.User.Identity.Name get the name as I want thanks –  FarOoOosa Aug 14 '12 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.