Skip to content

Core\Ldap\Ad\GroupType::isDomainLocal

$groupType->isDomainLocal(): bool

Checks if a group is a domain local group. The result is true or false.

A domain local group can have members from any domain. It can only be given permissions in its own domain. The groups under CN=Builtin, such as Administrators, are domain local.

A group has exactly one scope: global, domain local or universal. isDomainLocal reads the bit 0x4 of groupType.

Return value

Returns bool. true when the bit is set, and false when it is not.

Changelog

VersionChange
0.0.6Every Core\Ldap\Ad\GroupType method that checks a flag now starts with is, for example isGlobal() and isSecurityGroup(). The old names were system, global, domainLocal, universal, appBasic, appQuery and security.

Examples

The examples below run with this configuration file.

nvs.toml
# These examples use the LDAP directory server on this computer at port 16636.
# `tls_ca_file` is the certificate that the server's certificate is checked against.
[ldap.corp]
url = "ldaps://127.0.0.1:16636"
base = "DC=example,DC=test"
user = "CN=Reader,OU=Company,DC=example,DC=test"
password = "Novis-reader-1"
tls_ca_file = "../../../../../tests/db/ca.crt"
timeout = "5s"
# The program may open the `corp` directory.
[capabilities.ldap]
connect = ["corp"]

A domain local group

<?nvs
// Shows that `isDomainLocal` returns `true` for a group with the domain local scope.
// requires: samba-ad
var $corp = Core\Ldap::connect('corp');
var $type = $corp->read('CN=Cert Publishers,CN=Users,DC=example,DC=test', { select: ['groupType'] })?->groupType();
if ($type != null) {
// This prints `domainLocal: true`.
echo 'domainLocal: ', $type->isDomainLocal() ? 'true' : 'false', "\n";
}
Output
domainLocal: true

A built in group

<?nvs
// Shows that a built-in group is domain local, and was created by the system.
// requires: samba-ad
var $corp = Core\Ldap::connect('corp');
var $type = $corp->read('CN=Users,CN=Builtin,DC=example,DC=test', { select: ['groupType'] })?->groupType();
if ($type != null) {
// This prints `domainLocal: true, system: true`.
echo 'domainLocal: ', $type->isDomainLocal() ? 'true' : 'false';
echo ', system: ', $type->isSystemGroup() ? 'true' : 'false', "\n";
}
Output
domainLocal: true, system: true

Make a group domain local

<?nvs
// Shows how to get the `groupType` number for a group that changes to domain local.
// requires: samba-ad
var $corp = Core\Ldap::connect('corp');
var $type = $corp->read('CN=Employees,OU=Company,DC=example,DC=test', { select: ['groupType'] })?->groupType();
if ($type != null) {
// A group has one scope, so clear the `global` flag and set the `domainLocal` flag together.
var $local = $type->with({ global: false, domainLocal: true });
// This prints `domainLocal: true` and then `-2147483644`.
echo 'domainLocal: ', $local->isDomainLocal() ? 'true' : 'false', "\n";
echo $local->bits(), "\n";
}
Output
domainLocal: true
-2147483644