Core\Ldap\Ad\GroupType::isGlobal
$groupType->isGlobal(): boolChecks if a group is a global group. The result is true or false.
A global group can only have members from its own domain. Other domains can still use it, for example to give it permissions. A new group in Active Directory is global unless you choose another scope.
A group has exactly one scope: global, domain local or universal. isGlobal reads the bit 0x2 of groupType.
Return value
Returns bool. true when the bit is set, and false when it is not.
Changelog
| Version | Change |
|---|---|
0.0.6 | Every 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.
# 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 global group
<?nvs// Shows that `isGlobal` returns `true` for a group with the global scope.// 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) { // This prints `global: true`. echo 'global: ', $type->isGlobal() ? 'true' : 'false', "\n";}global: trueA group of another scope
<?nvs// Shows that `isGlobal` returns `false` for a group with another scope.// requires: samba-ad
var $corp = Core\Ldap::connect('corp');var $type = $corp->read('CN=Enterprise Admins,CN=Users,DC=example,DC=test', { select: ['groupType'] })?->groupType();
if ($type != null) { // `Enterprise Admins` is a universal group. // This prints `global: false, universal: true`. echo 'global: ', $type->isGlobal() ? 'true' : 'false'; echo ', universal: ', $type->isUniversal() ? 'true' : 'false', "\n";}global: false, universal: trueList the global groups
<?nvs// Shows how to keep only the global groups from a search.// requires: samba-ad
var $corp = Core\Ldap::connect('corp');var $found = $corp->search( Core\Ldap\Filter::equals('objectClass', 'group'), { base: 'OU=Company,DC=example,DC=test', select: ['groupType'] },);
array<tainted string> $names = [];foreach ($found as Core\Ldap\Entry $group) { var $type = $group->groupType(); if ($type != null && $type->isGlobal()) { $names[] = $group->dn()->rdnValue(); }}
// The server sends entries in no fixed order, so the names are sorted.// A mailing list has a scope too, so this prints all three groups.foreach (Core\Arr::sort($names) as tainted string $name) { echo $name, "\n";}EmployeesManagersNewsletter