J
Jason
Hi
I have a ASP.NET application where i would like to authenticate the
connecting users according to the Local Users and Groups on the web server.
I have the following code in the ASP.NET project.
private static void Demand(string[] groups)
{
WindowsIdentity processIdentity = WindowsIdentity.GetCurrent();
Console.WriteLine(processIdentity.Name);
IPermission permission = null;
foreach(string strGroup in groups)
{
string strDomainAndGroup = strGroup;
if(strGroup.IndexOf ('\\') == -1)
{
strDomainAndGroup = Environment.MachineName + "\\" + strGroup;
}
if(permission == null)
{
permission = new PrincipalPermission(null, strDomainAndGroup);
}
else
{
permission = permission.Union(new PrincipalPermission(null,
strDomainAndGroup));
}
}
if(permission != null)
{
permission.Demand();
// Revert to self, so that all actions now happen as the
// process user, not as the impersonated user.
Win32.AdvApi.RevertToSelf();
}
}
but i get the following error when i hit the "permission.Demand();" line
Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
Exception Details: System.Security.SecurityException: Request for principal
permission failed.
I know it says i must change the application's trust level. but i dont know
how to do this? someone have an example? or a solution to my problem even?
it would be much appreciated... thanks.
Jason
I have a ASP.NET application where i would like to authenticate the
connecting users according to the Local Users and Groups on the web server.
I have the following code in the ASP.NET project.
private static void Demand(string[] groups)
{
WindowsIdentity processIdentity = WindowsIdentity.GetCurrent();
Console.WriteLine(processIdentity.Name);
IPermission permission = null;
foreach(string strGroup in groups)
{
string strDomainAndGroup = strGroup;
if(strGroup.IndexOf ('\\') == -1)
{
strDomainAndGroup = Environment.MachineName + "\\" + strGroup;
}
if(permission == null)
{
permission = new PrincipalPermission(null, strDomainAndGroup);
}
else
{
permission = permission.Union(new PrincipalPermission(null,
strDomainAndGroup));
}
}
if(permission != null)
{
permission.Demand();
// Revert to self, so that all actions now happen as the
// process user, not as the impersonated user.
Win32.AdvApi.RevertToSelf();
}
}
but i get the following error when i hit the "permission.Demand();" line
Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
Exception Details: System.Security.SecurityException: Request for principal
permission failed.
I know it says i must change the application's trust level. but i dont know
how to do this? someone have an example? or a solution to my problem even?
it would be much appreciated... thanks.
Jason