diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/ldb/swig/Ldb.py | 18 | ||||
-rw-r--r-- | source4/lib/ldb/swig/ldb.i | 18 |
2 files changed, 35 insertions, 1 deletions
diff --git a/source4/lib/ldb/swig/Ldb.py b/source4/lib/ldb/swig/Ldb.py index e78d56efda..c7e6191c8a 100644 --- a/source4/lib/ldb/swig/Ldb.py +++ b/source4/lib/ldb/swig/Ldb.py @@ -20,6 +20,15 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # +# +# Interface notes: +# +# - should an empty dn be represented as None, or an empty string? +# +# - should single-valued attributes be a string, or a list with one +# element? +# + from ldb import * # Global initialisation @@ -62,6 +71,9 @@ class LdbMessage: def __setattr__(self, attr, value): if attr == 'dn': self.msg.dn = ldb_dn_explode(self.msg, value) + if self.msg.dn == None: + err = LDB_ERR_INVALID_DN_SYNTAX + raise LdbError(err, ldb_strerror(err)) return self.__dict__[attr] = value @@ -78,6 +90,7 @@ class LdbMessage: for i in range(elt.num_values)] def __setitem__(self, key, value): + ldb_msg_remove_attr(self.msg, key) if type(value) in (list, tuple): [ldb_msg_add_value(self.msg, key, v) for v in value] else: @@ -99,6 +112,11 @@ class LdbMessage: def items(self): return [(k, self[k]) for k in self.keys()] + # Misc stuff + + def sanity_check(self): + return ldb_msg_sanity_check(self.msg) + class Ldb: """A class representing a binding to a ldb file.""" diff --git a/source4/lib/ldb/swig/ldb.i b/source4/lib/ldb/swig/ldb.i index 744857b0a5..09d3461c2a 100644 --- a/source4/lib/ldb/swig/ldb.i +++ b/source4/lib/ldb/swig/ldb.i @@ -199,13 +199,18 @@ struct ldb_result { * Wrap ldb functions */ -int ldb_global_init(void); +/* Initialisation */ +int ldb_global_init(void); struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx); +/* Error handling */ + const char *ldb_errstring(struct ldb_context *ldb); const char *ldb_strerror(int ldb_err); +/* Top-level ldb operations */ + int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_result **OUT); @@ -216,9 +221,20 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct int ldb_add(struct ldb_context *ldb, const struct ldb_message *message); +/* Ldb message operations */ + struct ldb_message *ldb_msg_new(void *mem_ctx); + struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); + int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *INPUT); +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); + +int ldb_msg_sanity_check(struct ldb_message *msg); + +/* DN operations */ + struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); + char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *dn); |