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