简体   繁体   中英

How to get username and role after login using ASP.NET? (integrated aspnetdb into my database)

I made ​​one website using ASP.NET, it manages students.I have built a database of students and aspnetdb database integration.When I login to get username and role, but do not know how.I need this to each member, they will have one single function, see timetable and their own information ... I want to know about this earlier. Hopefully someone will help me. Thank you!

You can get your login in the identity linked to current thread, identity implement IIdentity interface

link : http://msdn.microsoft.com/fr-fr/library/system.security.principal.iidentity.aspx

Firstly you get your CurrentPrincipal , parse your principal and return your identity

link : http://msdn.microsoft.com/fr-fr/library/system.threading.thread.currentprincipal.aspx

link : http://msdn.microsoft.com/fr-fr/library/system.security.principal.iprincipal.aspx

Note : you can override your identity and principal, but this suppose that you have added your principal with identity to current thread

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM