SmtpPermission.Intersect Method (IPermission)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Creates and returns a permission that is the intersection of the current permission and the specified permission.

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

public override IPermission Intersect(
	IPermission target
)

Parameters

target
Type: System.Security.IPermission

An IPermission to intersect with the current permission. It must be of the same type as the current permission.

Return Value

Type: System.Security.IPermission

An SmtpPermission that represents the intersection of the current permission and the specified permission. Returns null if the intersection is empty or target is null.

Exception Condition
ArgumentException

target is not an SmtpPermission.

The intersection of two permissions is a permission that describes the state they describe in common. Only a demand that passes both original permissions will pass the intersection.

The following code example creates a permission object that is the intersection of an existing permission with an object that grants full access to SMTP servers.

public static SmtpPermission IntersectionWithFull(SmtpPermission permission)
{
    SmtpPermission allAccess = new 
        SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
    return (SmtpPermission) permission.Intersect(allAccess);
}

.NET Framework
Available since 2.0
Return to top
Show: