From 26ece8f69772a0991a7299cdef8403a9ad1ad48a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Sep 2006 01:21:34 +0000 Subject: r18910: Change ldb_msg_add_string() to not actually add an attribute if the string is zero length. This allows callers to not have to worry about creating an invalid ldap attribute. See extensive discussion on samba-technical list :-) (This used to be commit 7a1db8c2a432b9ab59b29ee1bfce6c8fe8e981a2) --- source4/lib/ldb/common/ldb_msg.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4') diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 92c537a8fa..9fbb2cdf3e 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -227,6 +227,11 @@ int ldb_msg_add_string(struct ldb_message *msg, val.data = discard_const_p(uint8_t, str); val.length = strlen(str); + if (val.length == 0) { + /* allow empty strings as non-existant attributes */ + return LDB_SUCCESS; + } + return ldb_msg_add_value(msg, attr_name, &val); } -- cgit