Add tlda_add_mod_str
authorVolker Lendecke <vl@samba.org>
Mon, 8 Jun 2009 18:36:49 +0000 (20:36 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 8 Jun 2009 19:14:10 +0000 (21:14 +0200)
source3/include/tldap_util.h
source3/lib/tldap_util.c

index 1c993769d76ddb9463386129f0b253b93760fbe7..06b10364745adf7318f4e0f331293f07aac9cd16 100644 (file)
@@ -34,6 +34,8 @@ bool tldap_pull_binsid(struct tldap_message *msg, const char *attribute,
 bool tldap_add_mod_blobs(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
                         int mod_op, const char *attrib,
                         int num_values, DATA_BLOB *values);
+bool tldap_add_mod_str(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
+                      int mod_op, const char *attrib, const char *str);
 bool tldap_make_mod_blob(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
                         int *pnum_mods, struct tldap_mod **pmods,
                         const char *attrib, DATA_BLOB newval);
index 1b0c3446ee633e78d5655d1ba86d44b535a37b64..7c579162a53ec8a0e1b74c2c672046ae8e006d96 100644 (file)
@@ -172,6 +172,23 @@ bool tldap_add_mod_blobs(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
        return true;
 }
 
+bool tldap_add_mod_str(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
+                      int mod_op, const char *attrib, const char *str)
+{
+       DATA_BLOB utf8;
+       bool ret;
+
+       if (!convert_string_talloc(talloc_tos(), CH_UNIX, CH_UTF8, str,
+                                  strlen(str), &utf8.data, &utf8.length,
+                                  false)) {
+               return false;
+       }
+
+       ret = tldap_add_mod_blobs(mem_ctx, pmods, mod_op, attrib, 1, &utf8);
+       TALLOC_FREE(utf8.data);
+       return ret;
+}
+
 static bool tldap_make_mod_blob_int(struct tldap_message *existing,
                                    TALLOC_CTX *mem_ctx,
                                    int *pnum_mods, struct tldap_mod **pmods,