Range Permissions

  • 2 minutes to read

Range permissions use bookmarks to specify protected ranges (regions) in a document. While a document is protected, a range permission limits editing to a collection of users and user groups. Editable sections can be displayed with highlighting or enclosed in brackets, as illustrated in the following image.

XtraRichEdit_RangePermissions

The How to: Grant Editing Permissions in a Document topic provides a step-by-step guide on how to protect document ranges using the Rich Text Editor Ribbon UI.

Set Permissions in Code

Call the SubDocument.BeginUpdateRangePermissions method to retrieve a collection of range permissions.

Set the RichEditControlOptionsBase.Authentication property to the current user name to make the range editable. Edit permission for a range requires one of the following to be true:

Use the RichEditControlOptionsBase.RangePermissions property to set range highlighting and bracket options. Call the Document.Protect and Document.Unprotect methods to enable and disable document protection, respectively. These methods do not require user input. A password can be passed as an argument to the Document.Protect method to protect the document. Calling the Document.Unprotect method disables protection, without the need for a password. To prompt the user for a password, execute the ProtectDocumentCommand and the UnprotectDocumentCommand commands instead.

Users and Groups

The list of users available in the Editing Permissions dialog is generated from the document ranges with permissions. Users may be added at runtime: provide a custom service implementing the IUserListService interface and register this service with the RichEditControl.ReplaceService<T> method. The IUserListService.GetUsers method should return the list of added user names.

The user groups available in the Editing Permissions dialog is predefined. By default, the available groups are: Everyone, Administrators, Contributors, Owners, Editors and Current User. Groups other than Everyone have no special meaning. There is no built-in user name with elevated permissions.

NOTE

Users and groups range permissions are not compatible with Editing Restrictions in Microsoft Word. Only the predefined groups are saved in RTF format. Group names are not saved in DOC format.

The RichEditControl does not associate users with groups, so user names and group names are independent. Similar to users, groups can be added at runtime: provide a custom service implementing the IUserGroupListService interface and register this service with the RichEditControl.ReplaceService<T> method. The IUserGroupListService.GetUserGroups method should return the list of added group names.

See Also