Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DnsPermission.IsUnrestricted Method

Checks the overall permission state of the object.

Namespace: System.Net
Assembly: System (in system.dll)

public bool IsUnrestricted ()
public final boolean IsUnrestricted ()
public final function IsUnrestricted () : boolean

Return Value

true if the DnsPermission instance was created with PermissionState.Unrestricted; otherwise, false.

The following example uses the IsUnrestricted method to check the overall permission state of the object.

public void useDns() {
   // Create a DnsPermission instance.
   DnsPermission permission = new DnsPermission(PermissionState.Unrestricted);
   // Check for permission.
   permission.Demand();
   Console.WriteLine("Attributes and Values of DnsPermission instance :");
   // Print the attributes and values.
   PrintKeysAndValues(permission.ToXml().Attributes);
   // Check the permission state.
   if (permission.IsUnrestricted())
      Console.WriteLine("Overall permissions : Unrestricted");
   else
      Console.WriteLine("Overall permissions : Restricted");
}

private void PrintKeysAndValues(Hashtable myList) {
   // Get the enumerator that can iterate through the hash table.
   IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
   Console.WriteLine("\t-KEY-\t-VALUE-");
   while (myEnumerator.MoveNext())
      Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
   Console.WriteLine();
}

public void UseDns()
{
    // Create a DnsPermission instance.
    DnsPermission permission = 
        new DnsPermission(PermissionState.Unrestricted);

    // Check for permission.
    permission.Demand();
    Console.WriteLine("Attributes and Values of DnsPermission instance :");

    // Print the attributes and values.
    PrintKeysAndValues(permission.ToXml().get_Attributes());

    // Check the permission state.
    if (permission.IsUnrestricted()) {
        Console.WriteLine("Overall permissions : Unrestricted");
    }
    else {
        Console.WriteLine("Overall permissions : Restricted");
    }
} //UseDns

private void PrintKeysAndValues(Hashtable myList)
{
    // Get the enumerator that can iterate through the hash table.
    IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
    Console.WriteLine("\t-KEY-\t-VALUE-");
    while (myEnumerator.MoveNext()) {
        Console.WriteLine("\t{0}:\t{1}", myEnumerator.get_Key(),
            myEnumerator.get_Value());
    }
    Console.WriteLine();
} //PrintKeysAndValues

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.