Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ServiceSecurityContext Class

 

Represents the security context of a remote party. On the client, represents the service identity and, on the service, represents the client identity.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System::Object
  System.ServiceModel::ServiceSecurityContext

public ref class ServiceSecurityContext 

NameDescription
System_CAPS_pubmethodServiceSecurityContext(AuthorizationContext^)

Initializes a new instance of the ServiceSecurityContext class with the specified authorization parameters.

System_CAPS_pubmethodServiceSecurityContext(AuthorizationContext^, ReadOnlyCollection<IAuthorizationPolicy^>^)

Initializes a new instance of the ServiceSecurityContext class with the specified authorization parameters and collection of policies.

System_CAPS_pubmethodServiceSecurityContext(ReadOnlyCollection<IAuthorizationPolicy^>^)

Initializes a new instance of the ServiceSecurityContext class with the collection of policies object.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticAnonymous

Returns an instance of the ServiceSecurityContext class that contains an empty collection of claims, identities, and other context data that is usually used to represent an anonymous party.

System_CAPS_pubpropertyAuthorizationContext

Gets the authorization information for an instance of this class. The AuthorizationContext contains a collection of ClaimSet that the application can interrogate and retrieve the information of the party.

System_CAPS_pubpropertyAuthorizationPolicies

Gets the collection of policies associated with an instance of this class.

System_CAPS_pubpropertySystem_CAPS_staticCurrent

Gets the current ServiceSecurityContext.

System_CAPS_pubpropertyIsAnonymous

Gets a value that indicates whether the current client has provided credentials to the service.

System_CAPS_pubpropertyPrimaryIdentity

Gets the primary identity associated with the current setting.

System_CAPS_pubpropertyWindowsIdentity

Gets the Windows identity of the current setting.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The data is part of the SecurityMessageProperty for a message.

Use this class to obtain information about a remote security context at runtime. A security context is created when a client is successfully authenticated and authorized to access a method. When a message is successfully authenticated and authorized, the security information from the client and for the current service instance can be obtained from an instance of this class.

You can retrieve an instance of the ServiceSecurityContext from the Current property of the OperationContext class, or use it from within a service operation method, as shown in the following example.

A common use of the class is to retrieve the current set of claims for the purpose of identifying or authorizing a client when accessing a method. The ClaimSet class contains a collection of Claim objects, and each can be parsed to determine whether a specific claim is present. If the specified claim is provided, authorization can be granted. This functionality is provided by overriding the CheckAccessCore method of the ServiceAuthorizationManager class. For a complete example, see the Authorization Policy.

Note that under some circumstances, the IsAuthenticated property of the IIdentity interface returns true even if the remote client is authenticated as an anonymous user. (The PrimaryIdentity property returns an implementation of the IIdentity interface.) The following circumstances must be true for this to occur:

  • The service uses Windows authentication.

  • The service allows anonymous logons.

  • The binding is a <customBinding>.

  • The custom binding includes a <security> element.

  • The <security> element includes a <secureConversationBootstrap> with the requireSecurityContextCancellation attribute set to false.

The following example uses the ServiceSecurityContext class to provide information about the current security context. The code creates an instance of the StreamWriter class to write the information to a file.

No code example is currently available or this language may not be supported.

The following example shows an implementation of the CheckAccessCore method that uses the ServiceSecurityContext to parse a set of claims.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2017 Microsoft