function let(\LdapTools\Connection\LdapConnectionInterface $connection)
{
$connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
$this->setLdapConnection($connection);
$this->setDn('cn=foo,dc=foo,dc=bar');
$dn = $this->dn;
$groupSidHex = $this->groupSidHex;
$connection->execute(Argument::that(function ($operation) use($dn) {
return $operation->getFilter() == '(&(objectClass=*))' && $operation->getAttributes() == ['objectSid'] && $operation->getBaseDn() == $dn;
}))->willReturn(['count' => 1, ["objectsid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->userSidHex))], 0 => "objectsid", 'count' => 1, 'dn' => $this->dn]]);
$connection->execute(Argument::that(function ($operation) use($groupSidHex) {
return $operation->getFilter() == '(&(objectSid=' . $groupSidHex . '))' && $operation->getAttributes() == ['cn'];
}))->willReturn(['count' => 1, ["cn" => ["count" => 1, 0 => 'Domain Users'], 0 => "cn", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
$connection->execute(Argument::that(function ($operation) use($dn) {
return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(member=' . $dn . ')(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
}))->willReturn(['count' => 1, ["objectSid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->groupSidHex))], 0 => "objectSid", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
$connection->execute(Argument::that(function ($operation) use($dn) {
return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(member=foo)(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
}))->willReturn(['count' => 0]);
}