(char *)oc_el->values[oc_el->num_values-1].data);
}
+static int get_dom_sid_from_ldb_message(TALLOC_CTX *mem_ctx,
+ struct ldb_message *acl_res,
+ struct dom_sid **sid)
+{
+ struct ldb_message_element *sid_element;
+ enum ndr_err_code ndr_err;
+
+ sid_element = ldb_msg_find_element(acl_res, "objectSid");
+ if (!sid_element) {
+ *sid = NULL;
+ return LDB_SUCCESS;
+ }
+ *sid = talloc(mem_ctx, struct dom_sid);
+ if(!*sid) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ndr_err = ndr_pull_struct_blob(&sid_element->values[0], *sid, NULL, *sid,
+ (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return LDB_SUCCESS;
+}
+
+
static void acl_debug(struct security_descriptor *sd,
struct security_token *token,
struct ldb_dn *dn,
struct ldb_context *ldb = ldb_module_get_ctx(module);
struct ldb_result *acl_res;
struct security_descriptor *sd = NULL;
+ struct dom_sid *sid = NULL;
NTSTATUS status;
uint32_t access_granted;
static const char *acl_attrs[] = {
"nTSecurityDescriptor",
+ "objectSid",
NULL
};
if (!sd) {
return LDB_SUCCESS;
}
+ ret = get_dom_sid_from_ldb_message(mem_ctx, acl_res->msgs[0], &sid);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
status = sec_access_check_ds(sd, acl_user_token(module),
access,
&access_granted,
- tree);
+ tree,
+ sid);
if (!NT_STATUS_IS_OK(status)) {
acl_debug(sd,
acl_user_token(module),
static int acl_check_access_on_attribute(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct security_descriptor *sd,
+ struct dom_sid *rp_sid,
uint32_t access,
struct dsdb_attribute *attr)
{
int ret;
- struct ldb_context *ldb = ldb_module_get_ctx(module);
NTSTATUS status;
uint32_t access_granted;
struct object_tree *root = NULL;
struct object_tree *new_node = NULL;
- const struct dsdb_schema *schema = dsdb_get_schema(ldb);
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
struct security_token *token = acl_user_token(module);
if (attr) {
status = sec_access_check_ds(sd, token,
access,
&access_granted,
- root);
+ root,
+ rp_sid);
if (!NT_STATUS_IS_OK(status)) {
ret = LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
}
static int acl_check_access_on_class(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct security_descriptor *sd,
+ struct dom_sid *rp_sid,
uint32_t access,
const char *class_name)
{
status = sec_access_check_ds(sd, token,
access,
&access_granted,
- root);
+ root,
+ rp_sid);
if (!NT_STATUS_IS_OK(status)) {
ret = LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
}
struct acl_context *ac)
{
struct ldb_message_element *oc_el;
- struct ldb_message_element *allowedAttributes;
- struct ldb_message_element *allowedAttributesEffective;
struct ldb_context *ldb = ldb_module_get_ctx(module);
const struct dsdb_schema *schema = dsdb_get_schema(ldb);
TALLOC_CTX *mem_ctx;
}
if (ac->allowedAttributesEffective) {
struct security_descriptor *sd;
+ struct dom_sid *sid = NULL;
ldb_msg_remove_attr(msg, "allowedAttributesEffective");
if (ac->user_type == SECURITY_SYSTEM) {
for (i=0; attr_list && attr_list[i]; i++) {
ret = get_sd_from_ldb_message(mem_ctx, sd_msg, &sd);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ ret = get_dom_sid_from_ldb_message(mem_ctx, sd_msg, &sid);
+
if (ret != LDB_SUCCESS) {
return ret;
}
ret = acl_check_access_on_attribute(module,
msg,
sd,
+ sid,
SEC_ADS_WRITE_PROP,
attr);
if (ret == LDB_SUCCESS) {
const struct dsdb_schema *schema = dsdb_get_schema(ldb);
const struct dsdb_class *sclass;
struct security_descriptor *sd;
+ struct dom_sid *sid = NULL;
int i, j, ret;
if (ac->user_type == SECURITY_SYSTEM) {
if (ret != LDB_SUCCESS) {
return ret;
}
+ ret = get_dom_sid_from_ldb_message(msg, sd_msg, &sid);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
for (i=0; oc_el && i < oc_el->num_values; i++) {
sclass = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &oc_el->values[i]);
if (!sclass) {
ret = acl_check_access_on_class(module,
msg,
sd,
+ sid,
SEC_ADS_CREATE_CHILD,
sclass->possibleInferiors[j]);
if (ret == LDB_SUCCESS) {
struct ldb_message_element *rightsEffective;
int ret;
struct security_descriptor *sd;
+ struct dom_sid *sid = NULL;
uint32_t flags = 0;
/* Must remove any existing attribute, or else confusion reins */
if (ret != LDB_SUCCESS) {
return ret;
}
+ ret = get_dom_sid_from_ldb_message(msg, sd_msg, &sid);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
ret = acl_check_access_on_attribute(module,
msg,
sd,
+ sid,
SEC_STD_WRITE_OWNER,
NULL);
if (ret == LDB_SUCCESS) {
ret = acl_check_access_on_attribute(module,
msg,
sd,
+ sid,
SEC_STD_WRITE_DAC,
NULL);
if (ret == LDB_SUCCESS) {
ret = acl_check_access_on_attribute(module,
msg,
sd,
+ sid,
SEC_FLAG_SYSTEM_SECURITY,
NULL);
if (ret == LDB_SUCCESS) {
NTSTATUS status;
struct ldb_result *acl_res;
struct security_descriptor *sd;
+ struct dom_sid *sid = NULL;
TALLOC_CTX *tmp_ctx = talloc_new(req);
static const char *acl_attrs[] = {
"nTSecurityDescriptor",
"objectClass",
+ "objectSid",
NULL
};
goto fail;
}
+ ret = get_dom_sid_from_ldb_message(req, acl_res->msgs[0], &sid);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP,
&root, &new_node)) {
DEBUG(10, ("acl_modify: cannot add to object tree\n"));
status = sec_access_check_ds(sd, acl_user_token(module),
SEC_ADS_WRITE_PROP,
&access_granted,
- root);
+ root,
+ sid);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("Object %s nas no write property access\n",
status = sec_access_check_ds(sd, acl_user_token(module),
SEC_STD_WRITE_DAC,
&access_granted,
- NULL);
+ NULL,
+ sid);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("Object %s nas no write dacl access\n",
struct ldb_dn *newparent = ldb_dn_get_parent(req, req->op.rename.newdn);
struct ldb_context *ldb;
struct security_descriptor *sd = NULL;
+ struct dom_sid *sid = NULL;
struct ldb_result *acl_res;
const struct GUID *guid;
struct object_tree *root = NULL;
static const char *acl_attrs[] = {
"nTSecurityDescriptor",
"objectClass",
+ "objectSid",
NULL
};
if (!sd) {
return LDB_SUCCESS;
}
+ ret = get_dom_sid_from_ldb_message(req, acl_res->msgs[0], &sid);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
status = sec_access_check_ds(sd, acl_user_token(module),
SEC_ADS_WRITE_PROP,
&access_granted,
- root);
+ root,
+ sid);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("Object %s nas no wp on name\n",
status = sec_access_check_ds(sd, acl_user_token(module),
SEC_STD_DELETE,
&access_granted,
- NULL);
+ NULL,
+ sid);
if (NT_STATUS_IS_OK(status)) {
return ldb_next_request(module, req);
static const char *acl_attrs[] = {
"objectClass",
"nTSecurityDescriptor",
+ "objectSid",
NULL
};
int ret, i;
res = self.ldb_admin.search( self.base_dn, expression="(distinguishedName=%s,%s)" \
% ("CN=test_add_group1,OU=test_add_ou2,OU=test_add_ou1", self.base_dn) )
self.assertEqual( res, [])
-
-# ace is not inherited - filered out...
def test_add_granted_user(self):
""" 3 Testing OU with the rights of regular user granted the right 'Create User child objects' """
# This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS
self.fail()
+
+ def test_modify_u4(self):
+ """11 Grant WP to PRINCIPAL_SELF and test modify"""
+ # Creating acluser1
+ if self.SAMBA:
+ self.delete_force(self.ldb_admin, self.get_user_dn("acluser3"))
+ self.create_user(self.ldb_admin, self.get_user_dn("acluser3"))
+ self.enable_account(self.get_user_dn("acluser3"))
+ # Test if we have any additional groups for user than default
+ if self.WIN:
+ res = self.ldb_admin.search( self.base_dn, expression="(distinguishedName=%s)" \
+ % self.get_user_dn("acluser3") )
+ try:
+ self.assertEqual( res[0]["memberOf"][0], "" )
+ except KeyError:
+ pass
+ else:
+ self.fail()
+ # Create user connection that we will test with
+ ldb_user = self.get_ldb_connection("acluser3", "samba123@")
+ ldif = """
+dn: """ + self.get_user_dn("acluser3") + """
+changetype: modify
+add: adminDescription
+adminDescription: blah blah blah"""
+ try:
+ ldb_user.modify_ldif(ldif)
+ except LdbError, (num, _):
+ self.assertEquals(num, ERR_INSUFFICIENT_ACCESS_RIGHTS)
+ else:
+ # This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS
+ self.fail()
+
+ mod = "(OA;;WP;bf967919-0de6-11d0-a285-00aa003049e2;;PS)"
+ self.dacl_add_ace(self.get_user_dn("acluser3"), mod)
+ # Modify on attribute you have rights for
+ ldb_user.modify_ldif(ldif)
+ res = self.ldb_admin.search( self.base_dn, expression="(distinguishedName=%s)" \
+ % self.get_user_dn("acluser3"), attrs=["adminDescription"] )
+ self.assertEqual(res[0]["adminDescription"][0], "blah blah blah")
+
#enable these when we have search implemented
def _test_search_u1(self):
"""See if can prohibit user to read another User object"""