blob: 857378b8b629478f4d7925c266c5ca9b8b632c12 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Adldap\Models\Concerns;
4
5use Adldap\Models\Attributes\AccountControl;
6
7trait HasUserAccountControl
8{
9 /**
10 * Returns the users user account control integer.
11 *
12 * @return string
13 */
14 public function getUserAccountControl()
15 {
16 return $this->getFirstAttribute($this->schema->userAccountControl());
17 }
18
19 /**
20 * Returns the users user account control as an AccountControl object.
21 *
22 * @return AccountControl
23 */
24 public function getUserAccountControlObject()
25 {
26 return new AccountControl($this->getUserAccountControl());
27 }
28
29 /**
30 * Sets the users account control property.
31 *
32 * @param int|string|AccountControl $accountControl
33 *
34 * @return $this
35 */
36 public function setUserAccountControl($accountControl)
37 {
38 return $this->setAttribute($this->schema->userAccountControl(), (string) $accountControl);
39 }
40
41 /**
42 * Returns if the user is disabled.
43 *
44 * @return bool
45 */
46 public function isDisabled()
47 {
48 return ($this->getUserAccountControl() & AccountControl::ACCOUNTDISABLE) === AccountControl::ACCOUNTDISABLE;
49 }
50
51 /**
52 * Returns if the user is enabled.
53 *
54 * @return bool
55 */
56 public function isEnabled()
57 {
58 return $this->getUserAccountControl() === null ? false : !$this->isDisabled();
59 }
60}