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