This documentation is archived and is not being maintained.

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
Show: