mirror of
https://github.com/samba-team/samba.git
synced 2025-12-16 00:23:52 +03:00
r13354: Add tests to check that controls work properly
Fix asq module, add a second_stage_init to register with rootdse
Fix asq control ldap parsing routines (this was nasty to find out)
(This used to be commit 933a80397d)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
096c2dc103
commit
3721bca79d
@@ -197,9 +197,29 @@ static int asq(struct ldb_module *module, struct ldb_request *req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int asq_init_2(struct ldb_module *module)
|
||||||
|
{
|
||||||
|
struct ldb_request request;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
request.operation = LDB_REQ_REGISTER;
|
||||||
|
request.op.reg.oid = LDB_CONTROL_ASQ_OID;
|
||||||
|
request.controls = NULL;
|
||||||
|
|
||||||
|
ret = ldb_request(module->ldb, &request);
|
||||||
|
if (ret != LDB_SUCCESS) {
|
||||||
|
ldb_debug(module->ldb, LDB_DEBUG_ERROR, "asq: Unable to register control with rootdse!\n");
|
||||||
|
return LDB_ERR_OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldb_next_second_stage_init(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct ldb_module_ops asq_ops = {
|
static const struct ldb_module_ops asq_ops = {
|
||||||
.name = "asq",
|
.name = "asq",
|
||||||
.request = asq
|
.request = asq,
|
||||||
|
.second_stage_init = asq_init_2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[])
|
struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[])
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ static BOOL decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
|
|||||||
}
|
}
|
||||||
lac->src_attr_len = source_attribute.length;
|
lac->src_attr_len = source_attribute.length;
|
||||||
if (lac->src_attr_len) {
|
if (lac->src_attr_len) {
|
||||||
lac->source_attribute = talloc_memdup(lac, source_attribute.data, source_attribute.length);
|
lac->source_attribute = talloc_strndup(lac, source_attribute.data, source_attribute.length);
|
||||||
|
|
||||||
if (!(lac->source_attribute)) {
|
if (!(lac->source_attribute)) {
|
||||||
return False;
|
return False;
|
||||||
|
|||||||
@@ -37,13 +37,42 @@ for p in $PROTOCOLS; do
|
|||||||
|
|
||||||
testit "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
|
testit "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
|
||||||
|
|
||||||
nusers=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
|
nentries=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
|
||||||
echo "Found $nusers users"
|
echo "Found $nentries entries"
|
||||||
if [ $nusers -lt 10 ]; then
|
if [ $nentries -lt 10 ]; then
|
||||||
echo "Should have found at least 10 users"
|
echo "Should have found at least 10 entries"
|
||||||
failed=`expr $failed + 1`
|
failed=`expr $failed + 1`
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
echo "Test Paged Results Control"
|
||||||
|
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||||
|
if [ $nentries -lt 1 ]; then
|
||||||
|
echo "Paged Results Control test returned 0 items"
|
||||||
|
failed=`expr $failed + 1`
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Test Server Sort Control"
|
||||||
|
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||||
|
if [ $nentries -lt 1 ]; then
|
||||||
|
echo "Server Sort Control test returned 0 items"
|
||||||
|
failed=`expr $failed + 1`
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Test Extended DN Control"
|
||||||
|
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||||
|
if [ $nentries -lt 1 ]; then
|
||||||
|
echo "Extended DN Control test returned 0 items"
|
||||||
|
failed=`expr $failed + 1`
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Test Attribute Scope Query Control"
|
||||||
|
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b 'CN=Administrators,CN=Builtin,DC=samba,DC=example,DC=com' | grep sAMAccountName | wc -l`
|
||||||
|
if [ $nentries -lt 1 ]; then
|
||||||
|
echo "Attribute Scope Query test returned 0 items"
|
||||||
|
failed=`expr $failed + 1`
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
testit "CLDAP" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ LDAP-CLDAP || failed=`expr $failed + 1`
|
testit "CLDAP" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ LDAP-CLDAP || failed=`expr $failed + 1`
|
||||||
|
|||||||
Reference in New Issue
Block a user