hi,
Can I use IsInRole with customized objects?? Like I want to do some operations only for Employee while other only for Managers.
How can I achieve this?
hi,
Can I use IsInRole with customized objects?? Like I want to do some operations only for Employee while other only for Managers.
How can I achieve this?
Yes you can:
var isMgr = User.IsInRole("Managers");
if(isMgr){
DoManagerialWork();
}else{
AccessDenied();
}
but you have to wireup asp.net membership etc. in your (asp.net) application.
Make use of the built in features:
This is the way you can to id in a Windows Application
using System.Security.Principal;
...
var currentUser = WindowsIdentity.GetCurrent();
var winPrincipal = new WindowsPrincipal(currentUser);
if(winPrincipal.IsInRole("Employees")) {
// TODO: BANANAS
} else if (windPrincipal.IsInRole("Managers")) {
// TODO: APPLES
}
...
This is the way you can do it in ASP.NET:
if(User.IsInRole("Employees")) {
// TODO: BANANAS
} else if (User.IsInRole("Managers")) {
// TODO: APPLES
}
BANANS
and APPLES
would be what your users get ;-)