共用方式為


MSUserPolicy userPolicyWithTemplateDescriptor:userId:authenticationCallback:options:completionBlock method

This method creates a user policy based on the supplied template descriptor. The following method should be invoked from the main thread.

Signature

+ (MSAsyncControl *)userPolicyWithTemplateDescriptor:(MSTemplateDescriptor *)templateDescriptor
                                              userId:(NSString *)userId
                                       signedAppData:(NSDictionary *)signedAppData
                                     licenseMetadata:(MSLicenseMetadata*)licenseMetadata
                              authenticationCallback:(id<MSAuthenticationCallback>)authenticationCallback
                                             options:(MSUserPolicyCreationOptions)options
                                     completionBlock:(void(^)(MSUserPolicy *userPolicy, NSError *error))completionBlock;

Parameters

Name Datatype Notes
templateDescriptor
MSTemplateDescriptor *
Required. The object which defines the template used to create the policy.
userId
NSString *
The email address of the user for whom the templates are being retrieved.
This email address will be used to discover the RMS service instance (either AD RMS server or Azure RMS) that the user's organization is using.
authenticationCallback
id<MSAuthenticationCallback>) *
Callback method to be used for authorization.
signedAppData
NSDictionary *
licenseMetaData
MSLicenseMetadata *
If you want to enable document tracking, it must be initialized before creating the MSUserPolicy with the MSTemplateDescriptor object.
For more information, see How to: Use document tracking.
options
MSUserPolicyCreationOptions
Options for creating protection policy object (see MSUserPolicyCreationOptions)
completionBlock
void(^)(MSUserPolicy * userPolicy, NSError *error)
The created user policy.

Returns

A pointer to an MSAsyncControl object.

Defined in

MSUserPolicy.h

Supported Platforms

Minimum supported OS versions
iOS 7.0 and OS X 10.8

Remarks

If you want to use the document tracking feature, the licenseMetadata property must be initialized prior to creating the MSUserPolicy and you will need to register with the document tracking service via a call to registerForDocTracking:userId:authenticationCallback:completionBlock, otherwise this parameter can be left uninitialized (nil) and the call to registerForDocTracking:userId:authenticationCallback:completionBlock on the MSUserPolicy can be skipped.

An example usage of this method:

[MSUserPolicy userPolicyWithTemplateDescriptor:[templates objectAtIndex:0]
                                        userId:@"user@domain.com"
                        authenticationCallback:authenticationCallback
                                 signedAppData:appData
                               licenseMetadata:docTrackingData
                                       options:None
                               completionBlock:^(MSUserPolicy *userPolicy, NSError *error)