Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace Adldap\Models; |
| 4 | |
| 5 | use DateTime; |
| 6 | |
| 7 | /** |
| 8 | * Class RootDse. |
| 9 | * |
| 10 | * Represents the LDAP connections Root DSE record. |
| 11 | */ |
| 12 | class RootDse extends Model |
| 13 | { |
| 14 | /** |
| 15 | * Returns the hosts current time in unix timestamp format. |
| 16 | * |
| 17 | * @return int |
| 18 | */ |
| 19 | public function getCurrentTime() |
| 20 | { |
| 21 | $time = $this->getFirstAttribute($this->schema->currentTime()); |
| 22 | |
| 23 | return DateTime::createFromFormat($this->timestampFormat, $time)->getTimestamp(); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Returns the hosts current time in the models date format. |
| 28 | * |
| 29 | * @return string |
| 30 | */ |
| 31 | public function getCurrentTimeDate() |
| 32 | { |
| 33 | return (new DateTime())->setTimestamp($this->getCurrentTime())->format($this->dateFormat); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Returns the hosts configuration naming context. |
| 38 | * |
| 39 | * @return string |
| 40 | */ |
| 41 | public function getConfigurationNamingContext() |
| 42 | { |
| 43 | return $this->getFirstAttribute($this->schema->configurationNamingContext()); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the hosts schema naming context. |
| 48 | * |
| 49 | * @return string |
| 50 | */ |
| 51 | public function getSchemaNamingContext() |
| 52 | { |
| 53 | return $this->getFirstAttribute($this->schema->schemaNamingContext()); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the hosts DNS name. |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | public function getDnsHostName() |
| 62 | { |
| 63 | return $this->getFirstAttribute($this->schema->dnsHostName()); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns the current hosts server name. |
| 68 | * |
| 69 | * @return string |
| 70 | */ |
| 71 | public function getServerName() |
| 72 | { |
| 73 | return $this->getFirstAttribute($this->schema->serverName()); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the DN of the root domain NC for this DC's forest. |
| 78 | * |
| 79 | * @return mixed |
| 80 | */ |
| 81 | public function getRootDomainNamingContext() |
| 82 | { |
| 83 | return $this->getFirstAttribute($this->schema->rootDomainNamingContext()); |
| 84 | } |
| 85 | } |