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