kamagra how much to take

How To Use PolicyLevel Objects For Display And Debugging

PolicyLevel objects are great when you are working with CLR level security since there are both several useful properties, as well as all being documented. Coming from the SharePoint OM world that is a breath of fresh air.

Working with PolicyLevel objects is pretty straight forward, as the name implies these objects represent security policy levels for the runtime, used to compute the permission grant. As such, for things like querying assemblies for permission correlation, or permissions set’s directly, PolicyLevel‘s let you do all that sort of fun stuff!

Consider the below example. Firstly, I am going to drill down and get all assemblies that have full trust using the FullTrustAssemblies property.

  1. IEnumerator enumerator = myPolicy.FullTrustAssemblies.GetEnumerator();
  2. for (int i = 1; enumerator.MoveNext(); i++)
  3. {
  4. var current = (StrongNameMembershipCondition)enumerator.Current;
  5. var builder = new StringBuilder();
  6. builder.AppendFormat("{0} | ", i);
  7. if (current.Name != null)
  8. {
  9. builder.Append(current.Name);
  10. }
  11. }

Next, I am going to use the NamedPermissionSets property, loop through it and display the policy levels permission sets.

  1. IEnumerator enumerator = level.NamedPermissionSets.GetEnumerator();
  2. for (var i = 1; enumerator.MoveNext(); i++)
  3. {
  4. var current = (NamedPermissionSet)enumerator.Current;
  5. var builder = new StringBuilder();
  6. builder.AppendFormat("{0} | {1}", i, current.Name);
  7. }

Lots of possibilities.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>