|
|
59dcbd |
From fc48976e49ebffb6db8b640eebcc3015e55a886f Mon Sep 17 00:00:00 2001
|
|
|
59dcbd |
From: Sumit Bose <sbose@redhat.com>
|
|
|
59dcbd |
Date: Tue, 30 Jan 2018 14:44:45 +0100
|
|
|
59dcbd |
Subject: [PATCH 4/9] library: add _adcli_ldap_parse_sid()
|
|
|
59dcbd |
|
|
|
59dcbd |
Get a binary SID from a LDAP message and return it in the string
|
|
|
59dcbd |
representation.
|
|
|
59dcbd |
|
|
|
59dcbd |
https://bugs.freedesktop.org/show_bug.cgi?id=100118
|
|
|
59dcbd |
|
|
|
59dcbd |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
59dcbd |
---
|
|
|
59dcbd |
library/adldap.c | 24 ++++++++++++++++++++++++
|
|
|
59dcbd |
library/adprivate.h | 4 ++++
|
|
|
59dcbd |
2 files changed, 28 insertions(+)
|
|
|
59dcbd |
|
|
|
59dcbd |
diff --git a/library/adldap.c b/library/adldap.c
|
|
|
59dcbd |
index 7c7a01b..07dc373 100644
|
|
|
59dcbd |
--- a/library/adldap.c
|
|
|
59dcbd |
+++ b/library/adldap.c
|
|
|
59dcbd |
@@ -67,6 +67,30 @@ _adcli_ldap_handle_failure (LDAP *ldap,
|
|
|
59dcbd |
return defres;
|
|
|
59dcbd |
}
|
|
|
59dcbd |
|
|
|
59dcbd |
+char *
|
|
|
59dcbd |
+_adcli_ldap_parse_sid (LDAP *ldap,
|
|
|
59dcbd |
+ LDAPMessage *results,
|
|
|
59dcbd |
+ const char *attr_name)
|
|
|
59dcbd |
+{
|
|
|
59dcbd |
+ LDAPMessage *entry;
|
|
|
59dcbd |
+ struct berval **bvs;
|
|
|
59dcbd |
+ char *val = NULL;
|
|
|
59dcbd |
+
|
|
|
59dcbd |
+ entry = ldap_first_entry (ldap, results);
|
|
|
59dcbd |
+ if (entry != NULL) {
|
|
|
59dcbd |
+ bvs = ldap_get_values_len (ldap, entry, attr_name);
|
|
|
59dcbd |
+ if (bvs != NULL) {
|
|
|
59dcbd |
+ if (bvs[0]) {
|
|
|
59dcbd |
+ val = _adcli_bin_sid_to_str ( (uint8_t *) bvs[0]->bv_val,
|
|
|
59dcbd |
+ bvs[0]->bv_len);
|
|
|
59dcbd |
+ return_val_if_fail (val != NULL, NULL);
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ ldap_value_free_len (bvs);
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+
|
|
|
59dcbd |
+ return val;
|
|
|
59dcbd |
+}
|
|
|
59dcbd |
|
|
|
59dcbd |
char *
|
|
|
59dcbd |
_adcli_ldap_parse_value (LDAP *ldap,
|
|
|
59dcbd |
diff --git a/library/adprivate.h b/library/adprivate.h
|
|
|
59dcbd |
index 7257c93..83a88f6 100644
|
|
|
59dcbd |
--- a/library/adprivate.h
|
|
|
59dcbd |
+++ b/library/adprivate.h
|
|
|
59dcbd |
@@ -174,6 +174,10 @@ adcli_result _adcli_ldap_handle_failure (LDAP *ldap,
|
|
|
59dcbd |
const char *desc,
|
|
|
59dcbd |
...) GNUC_PRINTF(3, 4);
|
|
|
59dcbd |
|
|
|
59dcbd |
+char * _adcli_ldap_parse_sid (LDAP *ldap,
|
|
|
59dcbd |
+ LDAPMessage *results,
|
|
|
59dcbd |
+ const char *attr_name);
|
|
|
59dcbd |
+
|
|
|
59dcbd |
char * _adcli_ldap_parse_value (LDAP *ldap,
|
|
|
59dcbd |
LDAPMessage *results,
|
|
|
59dcbd |
const char *attr_name);
|
|
|
59dcbd |
--
|
|
|
59dcbd |
2.14.4
|
|
|
59dcbd |
|