You need to sign in to do that
Don't have an account?

How to identify the logged in user id, when the User has logged in as another User
Hi,
I have 2 users A and B. User A has Admin profile and so has the option to login as other users.
Now lets say, User A logged into the system and logged in as User B.
Now, when I try to get the loggen in user Id using Userinfo.getUserId() or any other apex method, I get the User B record id.
Is there a way, I can get the actual logged user i.e., User A record Id
I have 2 users A and B. User A has Admin profile and so has the option to login as other users.
Now lets say, User A logged into the system and logged in as User B.
Now, when I try to get the loggen in user Id using Userinfo.getUserId() or any other apex method, I get the User B record id.
Is there a way, I can get the actual logged user i.e., User A record Id
UserInfo.getUserId() - returns the current User Id
User Usr = new User();
Usr = [SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()];
the above code will return the current user's Phone and Id who execute this code.
go through the below links:
http://salesforce.stackexchange.com/questions/18108/how-to-get-the-current-user-profile-in-apex-class
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000906dIAA
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm
Thanks,
Rockzz
Thanks for your reply.
If we try Userinfo.getUserId(), it just returns the User B record id. But what I want is the User A record id.
Regards,
MK
The only location where this is available to my knowledge is in the Audit Log, which you can download as a CSV file, but can't get in Apex / Visualforce.
did you find a solution for this problem? I have the same problem and want to know when a sysadmin log in as an another user.
Thank you.
Marco.
Did you find a solution for this problem?
Thanks
Akshay
you an try below option to find this manually,
There is the Setup Audit Trail which tells you who logged in as another person.
Setup > Security Controls > View Setup Audit Trail
Thanks
Manmohan
Did you find any solution for this problem??
Thanks,
sandeep