summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-07-16 11:08:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:38 -0500
commit809c9d4d3136cc46dc228107918ca19d5a008a0a (patch)
tree78d6ec07fcadd9f7f04d8de970948e99bba7ea20
parent2fc53c947b6c18f5e9761a26792f806ff588e239 (diff)
downloadsamba-809c9d4d3136cc46dc228107918ca19d5a008a0a.tar.gz
samba-809c9d4d3136cc46dc228107918ca19d5a008a0a.tar.bz2
samba-809c9d4d3136cc46dc228107918ca19d5a008a0a.zip
r23888: move elements belonging to the current ldap connection to a
substructure. metze (This used to be commit 00909194a6c1ed193dfdb296f50f58a53450583c)
-rw-r--r--source3/include/ads.h23
-rw-r--r--source3/libads/ldap.c92
-rw-r--r--source3/libads/ldap_printer.c2
-rw-r--r--source3/libads/ldap_utils.c4
-rw-r--r--source3/libads/sasl.c12
-rw-r--r--source3/libsmb/namequery_dc.c4
-rw-r--r--source3/printing/nt_printing.c2
-rw-r--r--source3/utils/net_ads.c26
8 files changed, 84 insertions, 81 deletions
diff --git a/source3/include/ads.h b/source3/include/ads.h
index 85c87bfeee..179aa742f2 100644
--- a/source3/include/ads.h
+++ b/source3/include/ads.h
@@ -15,16 +15,7 @@ enum wb_posix_mapping {
WB_POSIX_MAP_UNIXINFO = 4
};
-typedef struct {
-#ifdef HAVE_LDAP
- LDAP *ld;
-#else
- void *ld; /* the active ldap structure */
-#endif
- struct in_addr ldap_ip; /* the ip of the active connection, if any */
- time_t last_attempt; /* last attempt to reconnect */
- int ldap_port;
-
+typedef struct {
int is_mine; /* do I own this structure's memory? */
/* info needed to find the server */
@@ -61,6 +52,18 @@ typedef struct {
char *schema_path;
char *config_path;
} config;
+
+ /* info about the current LDAP connection */
+ struct {
+#ifdef HAVE_LDAP
+ LDAP *ld;
+#else
+ void *ld; /* the active ldap structure */
+#endif
+ struct in_addr ip; /* the ip of the active connection, if any */
+ time_t last_attempt; /* last attempt to reconnect */
+ int port;
+ } ldap;
} ADS_STRUCT;
/* used to remember the names of the posix attributes in AD */
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index c5c43c44c5..c8f68546ad 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -224,8 +224,8 @@ BOOL ads_try_connect(ADS_STRUCT *ads, const char *server )
ads->server.workgroup = SMB_STRDUP(cldap_reply.netbios_domain);
- ads->ldap_port = LDAP_PORT;
- ads->ldap_ip = *interpret_addr2(srv);
+ ads->ldap.port = LDAP_PORT;
+ ads->ldap.ip = *interpret_addr2(srv);
SAFE_FREE(srv);
/* Store our site name. */
@@ -372,8 +372,8 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
ADS_STATUS status;
NTSTATUS ntstatus;
- ads->last_attempt = time(NULL);
- ads->ld = NULL;
+ ads->ldap.last_attempt = time(NULL);
+ ads->ldap.ld = NULL;
/* try with a user specified server */
@@ -390,7 +390,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
return ADS_ERROR_NT(ntstatus);
got_connection:
- DEBUG(3,("Connected to LDAP server %s\n", inet_ntoa(ads->ldap_ip)));
+ DEBUG(3,("Connected to LDAP server %s\n", inet_ntoa(ads->ldap.ip)));
if (!ads->auth.user_name) {
/* Must use the userPrincipalName value here or sAMAccountName
@@ -404,7 +404,7 @@ got_connection:
}
if (!ads->auth.kdc_server) {
- ads->auth.kdc_server = SMB_STRDUP(inet_ntoa(ads->ldap_ip));
+ ads->auth.kdc_server = SMB_STRDUP(inet_ntoa(ads->ldap.ip));
}
#if KRB5_DNS_HACK
@@ -426,7 +426,7 @@ got_connection:
/* Otherwise setup the TCP LDAP session */
- if ( (ads->ld = ldap_open_with_timeout(ads->config.ldap_server_name,
+ if ( (ads->ldap.ld = ldap_open_with_timeout(ads->config.ldap_server_name,
LDAP_PORT, lp_ldap_timeout())) == NULL )
{
return ADS_ERROR(LDAP_OPERATIONS_ERROR);
@@ -434,13 +434,13 @@ got_connection:
/* cache the successful connection for workgroup and realm */
if (ads_closest_dc(ads)) {
- saf_store( ads->server.workgroup, inet_ntoa(ads->ldap_ip));
- saf_store( ads->server.realm, inet_ntoa(ads->ldap_ip));
+ saf_store( ads->server.workgroup, inet_ntoa(ads->ldap.ip));
+ saf_store( ads->server.realm, inet_ntoa(ads->ldap.ip));
}
- ldap_set_option(ads->ld, LDAP_OPT_PROTOCOL_VERSION, &version);
+ ldap_set_option(ads->ldap.ld, LDAP_OPT_PROTOCOL_VERSION, &version);
- status = ADS_ERROR(smb_ldap_start_tls(ads->ld, version));
+ status = ADS_ERROR(smb_ldap_start_tls(ads->ldap.ld, version));
if (!ADS_ERR_OK(status)) {
return status;
}
@@ -455,11 +455,11 @@ got_connection:
/* Now do the bind */
if (ads->auth.flags & ADS_AUTH_ANON_BIND) {
- return ADS_ERROR(ldap_simple_bind_s( ads->ld, NULL, NULL));
+ return ADS_ERROR(ldap_simple_bind_s( ads->ldap.ld, NULL, NULL));
}
if (ads->auth.flags & ADS_AUTH_SIMPLE_BIND) {
- return ADS_ERROR(ldap_simple_bind_s( ads->ld, ads->auth.user_name, ads->auth.password));
+ return ADS_ERROR(ldap_simple_bind_s( ads->ldap.ld, ads->auth.user_name, ads->auth.password));
}
return ads_sasl_bind(ads);
@@ -471,9 +471,9 @@ got_connection:
**/
void ads_disconnect(ADS_STRUCT *ads)
{
- if (ads->ld) {
- ldap_unbind(ads->ld);
- ads->ld = NULL;
+ if (ads->ldap.ld) {
+ ldap_unbind(ads->ldap.ld);
+ ads->ldap.ld = NULL;
}
}
@@ -616,7 +616,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
}
/* Paged results only available on ldap v3 or later */
- ldap_get_option(ads->ld, LDAP_OPT_PROTOCOL_VERSION, &version);
+ ldap_get_option(ads->ldap.ld, LDAP_OPT_PROTOCOL_VERSION, &version);
if (version < LDAP_VERSION3) {
rc = LDAP_NOT_SUPPORTED;
goto done;
@@ -693,9 +693,9 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
leaving this in despite the control that says don't generate
referrals, in case the server doesn't support it (jmcd)
*/
- ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
+ ldap_set_option(ads->ldap.ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
- rc = ldap_search_with_timeout(ads->ld, utf8_path, scope, utf8_expr,
+ rc = ldap_search_with_timeout(ads->ldap.ld, utf8_path, scope, utf8_expr,
search_attrs, 0, controls,
NULL, LDAP_NO_LIMIT,
(LDAPMessage **)res);
@@ -709,7 +709,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
goto done;
}
- rc = ldap_parse_result(ads->ld, *res, NULL, NULL, NULL,
+ rc = ldap_parse_result(ads->ldap.ld, *res, NULL, NULL, NULL,
NULL, &rcontrols, 0);
if (!rcontrols) {
@@ -928,9 +928,9 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
}
/* see the note in ads_do_paged_search - we *must* disable referrals */
- ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
+ ldap_set_option(ads->ldap.ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
- rc = ldap_search_with_timeout(ads->ld, utf8_path, scope, utf8_expr,
+ rc = ldap_search_with_timeout(ads->ldap.ld, utf8_path, scope, utf8_expr,
search_attrs, 0, NULL, NULL,
LDAP_NO_LIMIT,
(LDAPMessage **)res);
@@ -1007,7 +1007,7 @@ void ads_memfree(ADS_STRUCT *ads, void *mem)
{
char *utf8_dn, *unix_dn;
- utf8_dn = ldap_get_dn(ads->ld, msg);
+ utf8_dn = ldap_get_dn(ads->ldap.ld, msg);
if (!utf8_dn) {
DEBUG (5, ("ads_get_dn: ldap_get_dn failed\n"));
@@ -1237,7 +1237,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
for(i=0;(mods[i]!=0)&&(mods[i]!=(LDAPMod *) -1);i++);
/* make sure the end of the list is NULL */
mods[i] = NULL;
- ret = ldap_modify_ext_s(ads->ld, utf8_dn,
+ ret = ldap_modify_ext_s(ads->ldap.ld, utf8_dn,
(LDAPMod **) mods, controls, NULL);
SAFE_FREE(utf8_dn);
return ADS_ERROR(ret);
@@ -1265,7 +1265,7 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods)
/* make sure the end of the list is NULL */
mods[i] = NULL;
- ret = ldap_add_s(ads->ld, utf8_dn, (LDAPMod**)mods);
+ ret = ldap_add_s(ads->ldap.ld, utf8_dn, (LDAPMod**)mods);
SAFE_FREE(utf8_dn);
return ADS_ERROR(ret);
}
@@ -1285,7 +1285,7 @@ ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn)
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
- ret = ldap_delete_s(ads->ld, utf8_dn);
+ ret = ldap_delete_s(ads->ldap.ld, utf8_dn);
SAFE_FREE(utf8_dn);
return ADS_ERROR(ret);
}
@@ -1765,7 +1765,7 @@ ADS_STATUS ads_move_machine_acct(ADS_STRUCT *ads, const char *machine_name,
goto done;
}
- ldap_status = ldap_rename_s(ads->ld, computer_dn, computer_rdn,
+ ldap_status = ldap_rename_s(ads->ldap.ld, computer_dn, computer_rdn,
org_unit, 1, NULL, NULL);
rc = ADS_ERROR(ldap_status);
@@ -1952,10 +1952,10 @@ static BOOL ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
char *utf8_field;
BerElement *b;
- for (utf8_field=ldap_first_attribute(ads->ld,
+ for (utf8_field=ldap_first_attribute(ads->ldap.ld,
(LDAPMessage *)msg,&b);
utf8_field;
- utf8_field=ldap_next_attribute(ads->ld,
+ utf8_field=ldap_next_attribute(ads->ldap.ld,
(LDAPMessage *)msg,b)) {
struct berval **ber_vals;
char **str_vals, **utf8_vals;
@@ -1966,14 +1966,14 @@ static BOOL ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
string = fn(ads, field, NULL, data_area);
if (string) {
- utf8_vals = ldap_get_values(ads->ld,
+ utf8_vals = ldap_get_values(ads->ldap.ld,
(LDAPMessage *)msg, field);
str_vals = ads_pull_strvals(ctx,
(const char **) utf8_vals);
fn(ads, field, (void **) str_vals, data_area);
ldap_value_free(utf8_vals);
} else {
- ber_vals = ldap_get_values_len(ads->ld,
+ ber_vals = ldap_get_values_len(ads->ldap.ld,
(LDAPMessage *)msg, field);
fn(ads, field, (void **) ber_vals, data_area);
@@ -1997,7 +1997,7 @@ static BOOL ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
**/
int ads_count_replies(ADS_STRUCT *ads, void *res)
{
- return ldap_count_entries(ads->ld, (LDAPMessage *)res);
+ return ldap_count_entries(ads->ldap.ld, (LDAPMessage *)res);
}
/**
@@ -2008,7 +2008,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
**/
LDAPMessage *ads_first_entry(ADS_STRUCT *ads, LDAPMessage *res)
{
- return ldap_first_entry(ads->ld, res);
+ return ldap_first_entry(ads->ldap.ld, res);
}
/**
@@ -2019,7 +2019,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
**/
LDAPMessage *ads_next_entry(ADS_STRUCT *ads, LDAPMessage *res)
{
- return ldap_next_entry(ads->ld, res);
+ return ldap_next_entry(ads->ldap.ld, res);
}
/**
@@ -2038,7 +2038,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
char *ux_string;
size_t rc;
- values = ldap_get_values(ads->ld, msg, field);
+ values = ldap_get_values(ads->ldap.ld, msg, field);
if (!values)
return NULL;
@@ -2069,7 +2069,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
char **ret = NULL;
int i;
- values = ldap_get_values(ads->ld, msg, field);
+ values = ldap_get_values(ads->ldap.ld, msg, field);
if (!values)
return NULL;
@@ -2132,9 +2132,9 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
expected_range_attrib = talloc_asprintf(mem_ctx, "%s;Range=", field);
/* look for Range result */
- for (attr = ldap_first_attribute(ads->ld, (LDAPMessage *)msg, &ptr);
+ for (attr = ldap_first_attribute(ads->ldap.ld, (LDAPMessage *)msg, &ptr);
attr;
- attr = ldap_next_attribute(ads->ld, (LDAPMessage *)msg, ptr)) {
+ attr = ldap_next_attribute(ads->ldap.ld, (LDAPMessage *)msg, ptr)) {
/* we ignore the fact that this is utf8, as all attributes are ascii... */
if (strnequal(attr, expected_range_attrib, strlen(expected_range_attrib))) {
range_attr = attr;
@@ -2234,7 +2234,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
{
char **values;
- values = ldap_get_values(ads->ld, msg, field);
+ values = ldap_get_values(ads->ldap.ld, msg, field);
if (!values)
return False;
if (!values[0]) {
@@ -2259,7 +2259,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
char **values;
UUID_FLAT flat_guid;
- values = ldap_get_values(ads->ld, msg, "objectGUID");
+ values = ldap_get_values(ads->ldap.ld, msg, "objectGUID");
if (!values)
return False;
@@ -2289,7 +2289,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
struct berval **values;
BOOL ret = False;
- values = ldap_get_values_len(ads->ld, msg, field);
+ values = ldap_get_values_len(ads->ldap.ld, msg, field);
if (!values)
return False;
@@ -2317,7 +2317,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
BOOL ret;
int count, i;
- values = ldap_get_values_len(ads->ld, msg, field);
+ values = ldap_get_values_len(ads->ldap.ld, msg, field);
if (!values)
return 0;
@@ -2364,7 +2364,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
struct berval **values;
BOOL ret = False;
- values = ldap_get_values_len(ads->ld, msg, field);
+ values = ldap_get_values_len(ads->ldap.ld, msg, field);
if (!values) return False;
@@ -2481,7 +2481,7 @@ ADS_STATUS ads_current_time(ADS_STRUCT *ads)
/* establish a new ldap tcp session if necessary */
- if ( !ads->ld ) {
+ if ( !ads->ldap.ld ) {
if ( (ads_s = ads_init( ads->server.realm, ads->server.workgroup,
ads->server.ldap_server )) == NULL )
{
@@ -2542,7 +2542,7 @@ ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val)
/* establish a new ldap tcp session if necessary */
- if ( !ads->ld ) {
+ if ( !ads->ldap.ld ) {
if ( (ads_s = ads_init( ads->server.realm, ads->server.workgroup,
ads->server.ldap_server )) == NULL )
{
@@ -3100,7 +3100,7 @@ ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname)
hostnameDN = ads_get_dn(ads, (LDAPMessage *)msg);
- rc = ldap_delete_ext_s(ads->ld, hostnameDN, pldap_control, NULL);
+ rc = ldap_delete_ext_s(ads->ldap.ld, hostnameDN, pldap_control, NULL);
if (rc) {
DEBUG(3,("ldap_delete_ext_s failed with error code %d\n", rc));
}else {
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index cfddd4cc8a..0c6a280c36 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -43,7 +43,7 @@
if (ads_count_replies(ads, *res) != 1) {
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
}
- srv_dn = ldap_get_dn(ads->ld, *res);
+ srv_dn = ldap_get_dn(ads->ldap.ld, *res);
if (srv_dn == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index 16fd32b807..2f5c11b90c 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -38,8 +38,8 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
*res = NULL;
- if (!ads->ld &&
- time(NULL) - ads->last_attempt < ADS_RECONNECT_TIME) {
+ if (!ads->ldap.ld &&
+ time(NULL) - ads->ldap.last_attempt < ADS_RECONNECT_TIME) {
return ADS_ERROR(LDAP_SERVER_DOWN);
}
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 9536ba31be..a73545f8e5 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -75,7 +75,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
cred.bv_val = (char *)msg1.data;
cred.bv_len = msg1.length;
scred = NULL;
- rc = ldap_sasl_bind_s(ads->ld, NULL, "GSS-SPNEGO", &cred, NULL, NULL, &scred);
+ rc = ldap_sasl_bind_s(ads->ldap.ld, NULL, "GSS-SPNEGO", &cred, NULL, NULL, &scred);
data_blob_free(&msg1);
if ((rc != LDAP_SASL_BIND_IN_PROGRESS) && (rc != 0)) {
if (scred) {
@@ -157,7 +157,7 @@ static ADS_STATUS ads_sasl_spnego_krb5_bind(ADS_STRUCT *ads, const char *princip
cred.bv_val = (char *)blob.data;
cred.bv_len = blob.length;
- rc = ldap_sasl_bind_s(ads->ld, NULL, "GSS-SPNEGO", &cred, NULL, NULL, &scred);
+ rc = ldap_sasl_bind_s(ads->ldap.ld, NULL, "GSS-SPNEGO", &cred, NULL, NULL, &scred);
data_blob_free(&blob);
data_blob_free(&session_key);
@@ -183,7 +183,7 @@ static ADS_STATUS ads_sasl_spnego_bind(ADS_STRUCT *ads)
BOOL got_kerberos_mechanism = False;
#endif
- rc = ldap_sasl_bind_s(ads->ld, NULL, "GSS-SPNEGO", NULL, NULL, NULL, &scred);
+ rc = ldap_sasl_bind_s(ads->ldap.ld, NULL, "GSS-SPNEGO", NULL, NULL, NULL, &scred);
if (rc != LDAP_SASL_BIND_IN_PROGRESS) {
status = ADS_ERROR(rc);
@@ -397,7 +397,7 @@ static ADS_STATUS ads_sasl_gssapi_bind(ADS_STRUCT *ads)
cred.bv_val = (char *)output_token.value;
cred.bv_len = output_token.length;
- rc = ldap_sasl_bind_s(ads->ld, NULL, "GSSAPI", &cred, NULL, NULL,
+ rc = ldap_sasl_bind_s(ads->ldap.ld, NULL, "GSSAPI", &cred, NULL, NULL,
&scred);
if (rc != LDAP_SASL_BIND_IN_PROGRESS) {
status = ADS_ERROR(rc);
@@ -471,7 +471,7 @@ static ADS_STATUS ads_sasl_gssapi_bind(ADS_STRUCT *ads)
cred.bv_val = (char *)input_token.value;
cred.bv_len = input_token.length;
- rc = ldap_sasl_bind_s(ads->ld, NULL, "GSSAPI", &cred, NULL, NULL,
+ rc = ldap_sasl_bind_s(ads->ldap.ld, NULL, "GSSAPI", &cred, NULL, NULL,
&scred);
status = ADS_ERROR(rc);
@@ -515,7 +515,7 @@ ADS_STATUS ads_sasl_bind(ADS_STRUCT *ads)
status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
if (!ADS_ERR_OK(status)) return status;
- values = ldap_get_values(ads->ld, res, "supportedSASLMechanisms");
+ values = ldap_get_values(ads->ldap.ld, res, "supportedSASLMechanisms");
/* try our supported mechanisms in order */
for (i=0;sasl_mechanisms[i].name;i++) {
diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c
index 8c6e8e37af..0c1207d4e5 100644
--- a/source3/libsmb/namequery_dc.c
+++ b/source3/libsmb/namequery_dc.c
@@ -106,7 +106,7 @@ static BOOL ads_dc_name(const char *domain,
create_local_private_krb5_conf_for_domain(realm,
domain,
sitename,
- ads->ldap_ip);
+ ads->ldap.ip);
}
#endif
break;
@@ -123,7 +123,7 @@ static BOOL ads_dc_name(const char *domain,
fstrcpy(srv_name, ads->config.ldap_server_name);
strupper_m(srv_name);
- *dc_ip = ads->ldap_ip;
+ *dc_ip = ads->ldap.ip;
ads_destroy(&ads);
DEBUG(4,("ads_dc_name: using server='%s' IP=%s\n",
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index e28f0f0b02..944b695a9d 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3040,7 +3040,7 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
/* We use ldap_get_dn here as we need the answer
* in utf8 to call ldap_explode_dn(). JRA. */
- srv_dn_utf8 = ldap_get_dn((LDAP *)ads->ld, (LDAPMessage *)res);
+ srv_dn_utf8 = ldap_get_dn((LDAP *)ads->ldap.ld, (LDAPMessage *)res);
if (!srv_dn_utf8) {
ads_destroy(&ads);
return WERR_SERVER_UNAVAILABLE;
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 10d33fcfef..d4dfbb6a2b 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -80,13 +80,13 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads)
{
struct cldap_netlogon_reply reply;
- if ( !ads_cldap_netlogon( inet_ntoa(ads->ldap_ip), ads->server.realm, &reply ) ) {
+ if ( !ads_cldap_netlogon( inet_ntoa(ads->ldap.ip), ads->server.realm, &reply ) ) {
d_fprintf(stderr, "CLDAP query failed!\n");
return -1;
}
d_printf("Information for Domain Controller: %s\n\n",
- inet_ntoa(ads->ldap_ip));
+ inet_ntoa(ads->ldap.ip));
d_printf("Response Type: ");
switch (reply.type) {
@@ -160,7 +160,7 @@ static int net_ads_lookup(int argc, const char **argv)
if (!ads->config.realm) {
ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
- ads->ldap_port = 389;
+ ads->ldap.port = 389;
}
return net_ads_cldap_netlogon(ads);
@@ -189,11 +189,11 @@ static int net_ads_info(int argc, const char **argv)
d_fprintf( stderr, "Failed to get server's current time!\n");
}
- d_printf("LDAP server: %s\n", inet_ntoa(ads->ldap_ip));
+ d_printf("LDAP server: %s\n", inet_ntoa(ads->ldap.ip));
d_printf("LDAP server name: %s\n", ads->config.ldap_server_name);
d_printf("Realm: %s\n", ads->config.realm);
d_printf("Bind Path: %s\n", ads->config.bind_path);
- d_printf("LDAP port: %d\n", ads->ldap_port);
+ d_printf("LDAP port: %d\n", ads->ldap.port);
d_printf("Server time: %s\n", http_timestring(ads->config.current_time));
d_printf("KDC server: %s\n", ads->auth.kdc_server );
@@ -380,10 +380,10 @@ static int net_ads_workgroup(int argc, const char **argv)
if (!ads->config.realm) {
ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
- ads->ldap_port = 389;
+ ads->ldap.port = 389;
}
- if ( !ads_cldap_netlogon( inet_ntoa(ads->ldap_ip), ads->server.realm, &reply ) ) {
+ if ( !ads_cldap_netlogon( inet_ntoa(ads->ldap.ip), ads->server.realm, &reply ) ) {
d_fprintf(stderr, "CLDAP query failed!\n");
return -1;
}
@@ -545,7 +545,7 @@ static int ads_user_info(int argc, const char **argv)
return -1;
}
- grouplist = ldap_get_values((LDAP *)ads->ld,
+ grouplist = ldap_get_values((LDAP *)ads->ldap.ld,
(LDAPMessage *)res, "memberOf");
if (grouplist) {
@@ -831,7 +831,7 @@ static int net_ads_leave(int argc, const char **argv)
/* make RPC calls here */
- if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, &ads->ldap_ip,
+ if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, &ads->ldap.ip,
ads->config.ldap_server_name)) )
{
goto done;
@@ -1338,7 +1338,7 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,
char *root_dn;
ADS_STATUS ads_status;
- if ( !ads->ld ) {
+ if ( !ads->ldap.ld ) {
ads_status = ads_connect( ads );
if ( !ADS_ERR_OK(ads_status) ) {
DEBUG(0,("net_update_dns_internal: Failed to connect to our DC!\n"));
@@ -1568,7 +1568,7 @@ int net_ads_join(int argc, const char **argv)
password = talloc_strdup(ctx, tmp_password);
nt_status = net_join_domain(ctx, ads->config.ldap_server_name,
- &ads->ldap_ip, &short_domain_name, &domain_sid, password);
+ &ads->ldap.ip, &short_domain_name, &domain_sid, password);
if ( !NT_STATUS_IS_OK(nt_status) ) {
DEBUG(1, ("call of net_join_domain failed: %s\n",
get_friendly_nt_error_msg(nt_status)));
@@ -1603,7 +1603,7 @@ int net_ads_join(int argc, const char **argv)
/* Verify that everything is ok */
- if ( net_rpc_join_ok(short_domain_name, ads->config.ldap_server_name, &ads->ldap_ip) != 0 ) {
+ if ( net_rpc_join_ok(short_domain_name, ads->config.ldap_server_name, &ads->ldap.ip) != 0 ) {
d_fprintf(stderr, "Failed to verify membership in domain!\n");
goto fail;
}
@@ -1985,7 +1985,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
return -1;
}
- srv_dn = ldap_get_dn((LDAP *)ads->ld, (LDAPMessage *)res);
+ srv_dn = ldap_get_dn((LDAP *)ads->ldap.ld, (LDAPMessage *)res);
srv_cn = ldap_explode_dn(srv_dn, 1);
srv_cn_escaped = escape_rdn_val_string_alloc(srv_cn[0]);