Export (0) Print
Expand All

DnsPermission.IsUnrestricted Method

Checks the overall permission state of the object.

[Visual Basic]
Public Overridable Function IsUnrestricted() As Boolean Implements _
   IUnrestrictedPermission.IsUnrestricted
[C#]
public virtual bool IsUnrestricted();
[C++]
public: virtual bool IsUnrestricted();
[JScript]
public function IsUnrestricted() : Boolean;

Return Value

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

Implements

IUnrestrictedPermission.IsUnrestricted

Example

[Visual Basic, C#, C++] The following example uses the IsUnrestricted method to check the overall permission state of the object.

[Visual Basic] 
Public Sub useDns()
    ' Create a DnsPermission instance.
    Dim permission As 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() Then
        Console.WriteLine("Overall permissions : Unrestricted")
    Else
        Console.WriteLine("Overall permissions : Restricted")
    End If
End Sub 'useDns
 
Private Sub PrintKeysAndValues(myList As Hashtable)
    ' Get the enumerator that can iterate through the hash table.
    Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator()
    Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-")
    While myEnumerator.MoveNext()
        Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value)
    End While
    Console.WriteLine()
End Sub 'PrintKeysAndValues

[C#] 
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();
}

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

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DnsPermission Class | DnsPermission Members | System.Net Namespace

Show:
© 2014 Microsoft