c# - convert username to guid for asp.net validation using 'asp:login'/'SqlMembershipProvider'(membership) -


using 'asp:login' tag 'membership' in web.config file authenticate users. need query users without using 'asp:login' tag. need able convert string username (e.g., 'username') 'guid'/'userid' in database(e.g., '00000000-0000-0000...') in order this. there 'guid.parse/tryparse' method expects in '00000000-0000-0000...' format. appears in kind of hex format. there issue of password encrypted separate issue. thanks.

try this:

membershipuser user = membership.getuser(theusername); guid userid = (user == null) ? guid.empty : (guid)user.provideruserkey; 

the guid id of user stored in the provideruserkey property of the membershipuser class.

to retrieve instance of membershipuser class user specific username, need use the static membersip.getuser(username, userisonline) method. assuming you're querying user other current user, passing false userisonline parameter ensures don't affect user's last activity time.

alternatively, if are querying current user, can use the membersip.getuser() method, return membershipuser instance user logged on.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -