Create(BitCount: Integer; Value: Variant);
BitCount - number of access subjects, for which permissions may be determined.
Value - access mask. Mask value is set with 4-byte binary number. Each character of the binary number determines a permission on a relevant action of a defined security subject:
0 - action is forbidden.
1 - action is allowed.
Bit number corresponds to subjects sequence in a list on the Access Subjects tab if numbering starts with zero. Numbering is from right to left.
Mask value | ... 1 1 1 0 1 1 0 |
Subjects sequence in a list | ... 7 6 5 4 3 2 1 |
Mask value converted to a decimal form | 118 |
A mask may be set in a number and a character mode. A binary number must be converted to a decimal form to assign it in a number mode. To set it in a character mode the whole mask is divided into groups on 32 bits, then each group is converted to a decimal number. Spaces must be added to each received decimal number so that there must be 12 characters. A full string is made from received substrings. Consider the following example. Mask value in a binary mode (34 bits): 1010101010101010101010101010101010. To set it in a character mode, divide a string into groups: 10101010101010101010101010101010 and 10. Convert each group to a decimal form: 2863311530 and 2. Then add groups with spaces: "2863311530 " and "2 ". A string value necessary to transfer to the Value parameter: "2863311530 2 ".
The Create method creates an access attribute.
Executing the example requires that the repository contains an MDM dictionary with the DICT_1 identifier. 4 users or groups must exist in a list of access subjects for MDM dictionary.
Sub UserProc;
Var
MB: IMetabase;
MDesc: IMetabaseObjectDescriptor;
AOS: IAccessObjectSecurity;
Iterator: IAccessElementsIterator;
Level: integer;
Element: IAccessElement;
AttributeValue: IAccessAttributeValue;
Begin
MB := MetabaseClass.Active;
MDesc := MB.ItemById("DICT_1");
AOS := MDesc.GetSecurity;
Iterator := AOS.GetElements;
Level := Iterator.Next;
Element := Iterator.Current;
Element := Element.Edit;
AttributeValue := New AccessAttributeValue.Create(32, "12 "); // mask value is set in string form
Element.AttributeAccess(AccessElementAttributes.Read) := AttributeValue;
Element.Apply(AccessElementApplyOptions.ByHierarhy Or AccessElementApplyOptions.ByLevel);
End Sub UserProc;
After executing the example access permissions on reading the first element, all its child elements and elements located on the same level with the first are changed. Access to these elements is denied for the first two security subjects. Setting mask in a number mode is shown in the example for IAccessElement.Apply.
See also: