
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
944
|
Chapter 17: Security
When creating the PrincipalPermissions as part of the object construction, you are
using string representations of the built-in objects (
"BUILTIN\Administrators") to set
up the principal role. However, the names of these objects may be different depend-
ing on the locale the code runs under. It would be appropriate to use the
WindowsAccountType.Administrator enumeration value to ease localization since this
public void RefreshData( )
{
try
{
admPerm.Union(powerPerm.Union(userPerm)).Demand( );
Startup( );
Console.WriteLine("[SECPROXY] Data Refreshed");
coData.RefreshData( );
}
catch(SecurityException e)
{
Console.WriteLine("RefreshData Failed! {0}",e.ToString( ));
}
}
public void SaveNewData( )
{
try
{
admPerm.Union(powerPerm).Demand( );
Startup( );
Console.WriteLine("[SECPROXY] Data Saved");
coData.SaveNewData( );
}
catch(SecurityException e)
{
Console.WriteLine("SaveNewData Failed! {0}",e.ToString( ));
}
}
// DO NOT forget to use [#define DOTRACE] to control the tracing proxy.
private void Startup( )
{
if (coData == null)
{
#if (DOTRACE)
coData = new CompanyDataTraceProxy( );
#else
coData = new CompanyData( );
#endif
Console.WriteLine("[SECPROXY] Refresh Data");
coData.RefreshData( );
}
}
}
Example 17-3. CompanyDataSecProxy security proxy class (continued) ...