Building Security Layer

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,

I'm trying to implement a security object that i can call to check
access to different parts of the site eg something like:

PortalSecurity _new = new PortalSecurity();
if (_New.HasAccess()) { }

So that if i change from windows auth to something else, i can just
change the code in the PortalSecurity object.

I'm pretty sure that WindowsIdentity.GetCurrent().Name doesn't work when
being called in a object and not a aspx page or control.

So is there a way to get the current user from a object, or am i barking
up the wrong tree? Should i be looking at a custom IIdentity or
IPrinciple ?.

thanks,
 
Hi, Mark,

You can try:

System.Web.HttpContext.Current.User.Identity.Name

You will need to check for System.Web.HttpContext.Current.User != null

Hope this helps
Martin
 
Back
Top