Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Obtaining Security/Audit Information
|
985
One serious consideration with this approach is that the use of RequestRefuse marks
your assembly as partially trusted. This in turn prevents it from calling any strong-
named assembly that hasn’t been marked with the
AllowPartiallyTrustedCallers
attribute.
See Also
See Chapter 8 of Microsoft Patterns & Practices Group: http://msdn.microsoft.com/
library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh08.asp; see the “Secu-
rityAction Enumeration” and “Global Attributes” topics in the MSDN documentation.
17.13 Obtaining Security/Audit Information
Problem
You need to obtain the security rights and/or audit information for a file or registry
key.
Solution
When obtaining security/audit information for a file, use the static GetAccessControl
method of the File class to obtain a System.Security.AccessControl.FileSecurity
object. Use the FileSecurity object to access the security and audit information for
the file. These steps are demonstrated in Example 17-15.
Example 17-15. Obtaining security audit information
public static void ViewFileRights( )
{
// Get security information from a file.
string file = @"c:\FOO.TXT";
FileSecurity fileSec = File.GetAccessControl(file);
DisplayFileSecurityInfo(fileSec);
}
public static void DisplayFileSecurityInfo(FileSecurity ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata