#include "winbindd_rpc.h"
#include "lib/util_unixsids.h"
#include "rpc_client/rpc_client.h"
+#include "rpc_client/cli_pipe.h"
#include "../librpc/gen_ndr/ndr_samr_c.h"
#include "rpc_client/cli_samr.h"
#include "../librpc/gen_ndr/ndr_lsa_c.h"
return NT_STATUS_OK;
}
+static bool reset_connection_on_error(struct winbindd_domain *domain,
+ struct rpc_pipe_client *p,
+ NTSTATUS status)
+{
+ struct winbind_internal_pipes *internal_pipes = NULL;
+
+ internal_pipes = talloc_get_type_abort(
+ domain->private_data, struct winbind_internal_pipes);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_IO_DEVICE_ERROR))
+ {
+ TALLOC_FREE(internal_pipes);
+ domain->private_data = NULL;
+ return true;
+ }
+
+ if (!rpccli_is_connected(p)) {
+ TALLOC_FREE(internal_pipes);
+ domain->private_data = NULL;
+ return true;
+ }
+
+ return false;
+}
+
/*********************************************************************
SAM specific functions.
*********************************************************************/
uint32_t num_info = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_enum_dom_groups\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
&dom_pol,
&num_info,
&info);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
uint32_t *rids = NULL;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("samr_query_user_list\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
&dom_pol,
&domain->sid,
&rids);
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
uint32_t num_trusts = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("samr: trusted domains\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
NULL,
NULL,
&lsa_policy,
&num_trusts,
&trusts);
+
+ if (!retry && reset_connection_on_error(domain, lsa_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_lookup_groupmem\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
&names,
&name_types);
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (pnum_names) {
*pnum_names = num_names;
}
uint32_t num_info = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("samr: enum local groups\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
samr_pipe,
&dom_pol,
&num_info,
+
&info);
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
enum lsa_SidType type;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_name_to_sid\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
NULL,
NULL,
flags,
&sid,
&type);
+
+ if (!retry && reset_connection_on_error(domain, lsa_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
enum lsa_SidType type;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_sid_to_name\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
NULL,
NULL,
&name,
&type);
+ if (!retry && reset_connection_on_error(domain, lsa_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (ptype) {
*ptype = type;
}
char **names = NULL;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_rids_to_names for %s\n", domain->name));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
NULL,
NULL,
&domain_name,
&names,
&types);
+
+ if (!retry && reset_connection_on_error(domain, lsa_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
TALLOC_CTX *tmp_ctx;
NTSTATUS status, result;
struct dcerpc_binding_handle *b = NULL;
+ bool retry = false;
DEBUG(3,("sam_lockout_policy\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
DomainLockoutInformation,
&info,
&result);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto error;
}
TALLOC_CTX *tmp_ctx;
NTSTATUS status, result;
struct dcerpc_binding_handle *b = NULL;
+ bool retry = false;
DEBUG(3,("sam_password_policy\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
DomainPasswordInformation,
&info,
&result);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto error;
}
uint32_t num_groups = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_lookup_usergroups\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
user_sid,
&num_groups,
&user_grpsids);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
uint32_t *alias_rids = NULL;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("sam_lookup_useraliases\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
sids,
&num_aliases,
&alias_rids);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
uint32_t seq = DOM_SEQUENCE_NONE;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
+ bool retry = false;
DEBUG(3,("samr: sequence number\n"));
return NT_STATUS_NO_MEMORY;
}
+again:
status = open_cached_internal_pipe_conn(domain,
&samr_pipe,
&dom_pol,
&dom_pol,
domain->name,
&seq);
+
+ if (!retry && reset_connection_on_error(domain, samr_pipe, status)) {
+ retry = true;
+ goto again;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
goto done;
}