File 0009-library-add-_adcli_ldap_parse_sid.patch of Package adcli (Revision ce46d0e7322eb68daa00b5c190e5847d)
Currently displaying revision ce46d0e7322eb68daa00b5c190e5847d , Show latest
71
1
From 3c48f8c054990712faf76f12c95897e19c9c6f25 Mon Sep 17 00:00:00 2001
2
From: Sumit Bose <sbose@redhat.com>
3
Date: Tue, 30 Jan 2018 14:44:45 +0100
4
Subject: [PATCH 09/25] library: add _adcli_ldap_parse_sid()
5
6
Get a binary SID from a LDAP message and return it in the string
7
representation.
8
9
https://bugs.freedesktop.org/show_bug.cgi?id=100118
10
https://gitlab.freedesktop.org/realmd/adcli/issues/6
11
12
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
13
---
14
library/adldap.c | 24 ++++++++++++++++++++++++
15
library/adprivate.h | 4 ++++
16
2 files changed, 28 insertions(+)
17
18
diff --git a/library/adldap.c b/library/adldap.c
19
index 7c7a01b..07dc373 100644
20
--- a/library/adldap.c
21
+++ b/library/adldap.c
22
23
return defres;
24
}
25
26
+char *
27
+_adcli_ldap_parse_sid (LDAP *ldap,
28
+ LDAPMessage *results,
29
+ const char *attr_name)
30
+{
31
+ LDAPMessage *entry;
32
+ struct berval **bvs;
33
+ char *val = NULL;
34
+
35
+ entry = ldap_first_entry (ldap, results);
36
+ if (entry != NULL) {
37
+ bvs = ldap_get_values_len (ldap, entry, attr_name);
38
+ if (bvs != NULL) {
39
+ if (bvs[0]) {
40
+ val = _adcli_bin_sid_to_str ( (uint8_t *) bvs[0]->bv_val,
41
+ bvs[0]->bv_len);
42
+ return_val_if_fail (val != NULL, NULL);
43
+ }
44
+ ldap_value_free_len (bvs);
45
+ }
46
+ }
47
+
48
+ return val;
49
+}
50
51
char *
52
_adcli_ldap_parse_value (LDAP *ldap,
53
diff --git a/library/adprivate.h b/library/adprivate.h
54
index 7257c93..83a88f6 100644
55
--- a/library/adprivate.h
56
+++ b/library/adprivate.h
57
58
const char *desc,
59
...) GNUC_PRINTF(3, 4);
60
61
+char * _adcli_ldap_parse_sid (LDAP *ldap,
62
+ LDAPMessage *results,
63
+ const char *attr_name);
64
+
65
char * _adcli_ldap_parse_value (LDAP *ldap,
66
LDAPMessage *results,
67
const char *attr_name);
68
--
69
2.16.4
70
71