5

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

1 Answer 1

6

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 :)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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