|
|
59dcbd |
From 43fe15cc27ebf5f33234c30067a295ef0bd864bb Mon Sep 17 00:00:00 2001
|
|
|
59dcbd |
From: Sumit Bose <sbose@redhat.com>
|
|
|
59dcbd |
Date: Tue, 30 Jan 2018 14:40:46 +0100
|
|
|
59dcbd |
Subject: [PATCH 5/9] library: add lookup_domain_sid()
|
|
|
59dcbd |
|
|
|
59dcbd |
Read the domain SID from the default naming context AD object and store
|
|
|
59dcbd |
it in adcli_conn.
|
|
|
59dcbd |
|
|
|
59dcbd |
https://bugs.freedesktop.org/show_bug.cgi?id=100118
|
|
|
59dcbd |
|
|
|
59dcbd |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
59dcbd |
---
|
|
|
59dcbd |
library/adconn.c | 28 ++++++++++++++++++++++++++++
|
|
|
59dcbd |
1 file changed, 28 insertions(+)
|
|
|
59dcbd |
|
|
|
59dcbd |
diff --git a/library/adconn.c b/library/adconn.c
|
|
|
59dcbd |
index 67bdfd9..6b84b88 100644
|
|
|
59dcbd |
--- a/library/adconn.c
|
|
|
59dcbd |
+++ b/library/adconn.c
|
|
|
59dcbd |
@@ -72,6 +72,7 @@ struct _adcli_conn_ctx {
|
|
|
59dcbd |
char *domain_controller;
|
|
|
59dcbd |
char *canonical_host;
|
|
|
59dcbd |
char *domain_short;
|
|
|
59dcbd |
+ char *domain_sid;
|
|
|
59dcbd |
adcli_disco *domain_disco;
|
|
|
59dcbd |
char *default_naming_context;
|
|
|
59dcbd |
char *configuration_naming_context;
|
|
|
59dcbd |
@@ -1068,6 +1069,32 @@ lookup_short_name (adcli_conn *conn)
|
|
|
59dcbd |
}
|
|
|
59dcbd |
}
|
|
|
59dcbd |
|
|
|
59dcbd |
+static void
|
|
|
59dcbd |
+lookup_domain_sid (adcli_conn *conn)
|
|
|
59dcbd |
+{
|
|
|
59dcbd |
+ char *attrs[] = { "objectSid", NULL, };
|
|
|
59dcbd |
+ LDAPMessage *results;
|
|
|
59dcbd |
+ int ret;
|
|
|
59dcbd |
+
|
|
|
59dcbd |
+ free (conn->domain_sid);
|
|
|
59dcbd |
+ conn->domain_sid = NULL;
|
|
|
59dcbd |
+
|
|
|
59dcbd |
+ ret = ldap_search_ext_s (conn->ldap, conn->default_naming_context, LDAP_SCOPE_BASE,
|
|
|
59dcbd |
+ NULL, attrs, 0, NULL, NULL, NULL, -1, &results);
|
|
|
59dcbd |
+ if (ret == LDAP_SUCCESS) {
|
|
|
59dcbd |
+ conn->domain_sid = _adcli_ldap_parse_sid (conn->ldap, results, "objectSid");
|
|
|
59dcbd |
+ ldap_msgfree (results);
|
|
|
59dcbd |
+
|
|
|
59dcbd |
+ if (conn->domain_sid)
|
|
|
59dcbd |
+ _adcli_info ("Looked up domain SID: %s", conn->domain_sid);
|
|
|
59dcbd |
+ else
|
|
|
59dcbd |
+ _adcli_err ("No domain SID found");
|
|
|
59dcbd |
+ } else {
|
|
|
59dcbd |
+ _adcli_ldap_handle_failure (conn->ldap, ADCLI_ERR_DIRECTORY,
|
|
|
59dcbd |
+ "Couldn't lookup domain SID");
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+}
|
|
|
59dcbd |
+
|
|
|
59dcbd |
static void
|
|
|
59dcbd |
conn_clear_state (adcli_conn *conn)
|
|
|
59dcbd |
{
|
|
|
59dcbd |
@@ -1148,6 +1175,7 @@ adcli_conn_connect (adcli_conn *conn)
|
|
|
59dcbd |
return res;
|
|
|
59dcbd |
|
|
|
59dcbd |
lookup_short_name (conn);
|
|
|
59dcbd |
+ lookup_domain_sid (conn);
|
|
|
59dcbd |
return ADCLI_SUCCESS;
|
|
|
59dcbd |
}
|
|
|
59dcbd |
|
|
|
59dcbd |
--
|
|
|
59dcbd |
2.14.4
|
|
|
59dcbd |
|