struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg, 
				     const char *attr)
{
	ssize_t ret;
	const struct ldb_val *v;
	struct dom_sid *sid;
	v = ldb_msg_find_ldb_val(msg, attr);
	if (v == NULL) {
		return NULL;
	}
	sid = talloc(mem_ctx, struct dom_sid);
	if (sid == NULL) {
		return NULL;
	}
	ret = sid_parse(v->data, v->length, sid);
	if (ret == -1) {
		talloc_free(sid);
		return NULL;
	}
	return sid;
}
struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg, 
				     const char *attr)
{
	ssize_t ret;
	const struct ldb_val *v;
	struct dom_sid *sid;
	v = ldb_msg_find_ldb_val(msg, attr);
	if (v == NULL) {
		return NULL;
	}
	sid = talloc(mem_ctx, struct dom_sid);
	if (sid == NULL) {
		return NULL;
	}
	ret = sid_parse(v->data, v->length, sid);
	if (ret == -1) {
		talloc_free(sid);
		return NULL;
	}
	return sid;
}