diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-03 17:50:30 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-03 17:48:18 +0000 |
commit | b78bf4d72100f9aa8c50ee36b30ba353e2b72eae (patch) | |
tree | 68007f4266edd740289c6b596cdf207168825e6e /source4/dsdb/samdb/ldb_modules/util.c | |
parent | 4311438528aaf30fff878c3862fd1d76f6059f56 (diff) | |
download | samba-b78bf4d72100f9aa8c50ee36b30ba353e2b72eae.tar.gz samba-b78bf4d72100f9aa8c50ee36b30ba353e2b72eae.tar.bz2 samba-b78bf4d72100f9aa8c50ee36b30ba353e2b72eae.zip |
s4:samldb LDB module - improve the "get_single_valued_attr" call and move it into "ldb_modules/util.c"
It will be used by other LDB modules as well.
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/util.c')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c index e42bc7715e..7d6fcc47ad 100644 --- a/source4/dsdb/samdb/ldb_modules/util.c +++ b/source4/dsdb/samdb/ldb_modules/util.c @@ -1108,3 +1108,33 @@ void dsdb_req_chain_debug(struct ldb_request *req, int level) DEBUG(level, ("%s\n", s)); talloc_free(s); } + +/* + * Gets back a single-valued attribute by the rules of the DSDB triggers when + * performing a modify operation. + * + * In order that the constraint checking by the "objectclass_attrs" LDB module + * does work properly, the change request should remain similar or only be + * enhanced (no other modifications as deletions, variations). + */ +struct ldb_message_element *dsdb_get_single_valued_attr(struct ldb_message *msg, + const char *attr_name) +{ + struct ldb_message_element *el = NULL; + unsigned int i; + + /* We've to walk over all modification entries and consider the last + * non-delete one which belongs to "attr_name". + * + * If "el" is NULL afterwards then that means there was no interesting + * change entry. */ + for (i = 0; i < msg->num_elements; i++) { + if ((ldb_attr_cmp(msg->elements[i].name, attr_name) == 0) && + (LDB_FLAG_MOD_TYPE(msg->elements[i].flags) + != LDB_FLAG_MOD_DELETE)) { + el = &msg->elements[i]; + } + } + + return el; +} |