From 8c2d7ae19e5a14ffa37af60ff4eec4d79f70040b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Jan 2010 17:42:05 +1100 Subject: s4-dsdb: added samdb_ldb_val_case_cmp() --- source4/dsdb/common/util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 632025da54..139ea4dc6b 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -3198,3 +3198,19 @@ int dsdb_tombstone_lifetime(struct ldb_context *ldb, uint32_t *lifetime) talloc_free(dn); return LDB_SUCCESS; } + +/* + compare a ldb_val to a string case insensitively + */ +int samdb_ldb_val_case_cmp(const char *s, struct ldb_val *v) +{ + size_t len = strlen(s); + int ret; + if (len > v->length) return 1; + ret = strncasecmp(s, (const char *)v->data, v->length); + if (ret != 0) return ret; + if (v->length > len && v->data[len] != 0) { + return -1; + } + return 0; +} -- cgit