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:
virtual bool IsUnrestricted () sealed
public final boolean IsUnrestricted ()
public final function IsUnrestricted () : boolean
Not applicable.

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 = gcnew 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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: