DnsPermission.IsUnrestricted Method
.NET Framework 3.0
Checks the overall permission state of the object.
Namespace: System.Net
Assembly: System (in system.dll)
Assembly: System (in system.dll)
'Declaration Public Function IsUnrestricted As Boolean 'Usage Dim instance As DnsPermission Dim returnValue As Boolean returnValue = instance.IsUnrestricted
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 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
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.