0

I am using windows authentication in my application

if(User.IsInRole("Supervisor"))
{
//do something
}

which is working as expected.

Now i want to fetch a UserId of the logged in user from aspnet_Users table . I tried using Membership.GetUser , which did not worked.

Is there any way to do so?

Mandar Patil
  • 538
  • 2
  • 10
  • 29

1 Answers1

0

No direct way but you can use ProviderUserKey property of MembershipUser class like below:

        var user = Membership.GetUser(model.UserName);
        if (user != null)
        {
            var userId = user.ProviderUserKey;
        }
SBirthare
  • 5,117
  • 4
  • 34
  • 59