1<?php
2/**
3 * This file is part of the FreeDSx LDAP package.
4 *
5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11namespace FreeDSx\Ldap\Control\Ad;
12
13use FreeDSx\Asn1\Asn1;
14use FreeDSx\Asn1\Type\AbstractType;
15use FreeDSx\Ldap\Control\Control;
16
17/**
18 * Represents a SD Flags Control for Active Directory.
19 *
20 * SDFlagsRequestValue ::= SEQUENCE {
21 *     Flags    INTEGER
22 * }
23 *
24 * @see https://msdn.microsoft.com/en-us/library/cc223323.aspx
25 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
26 */
27class SdFlagsControl extends Control
28{
29    /**
30     * Owner identifier of the object.
31     */
32    public const OWNER_SECURITY_INFORMATION = 1;
33
34    /**
35     * Primary group identifier.
36     */
37    public const GROUP_SECURITY_INFORMATION = 2;
38
39    /**
40     * Discretionary access control list (DACL) of the object.
41     */
42    public const DACL_SECURITY_INFORMATION = 4;
43
44    /**
45     * System access control list (SACL) of the object.
46     */
47    public const SACL_SECURITY_INFORMATION = 8;
48
49    /**
50     * @var int
51     */
52    protected $flags;
53
54    /**
55     * @param int $flags
56     */
57    public function __construct(int $flags)
58    {
59        $this->flags = $flags;
60        parent::__construct(self::OID_SD_FLAGS);
61    }
62
63    /**
64     * @return int
65     */
66    public function getFlags(): int
67    {
68        return $this->flags;
69    }
70
71    /**
72     * @param int $flags
73     * @return $this
74     */
75    public function setFlags(int $flags)
76    {
77        $this->flags = $flags;
78
79        return $this;
80    }
81
82    public function toAsn1(): AbstractType
83    {
84        $this->controlValue = Asn1::sequence(Asn1::integer($this->flags));
85
86        return parent::toAsn1();
87    }
88}
89