summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-10-04 21:39:09 +0000
committerGerald Carter <jerry@samba.org>2002-10-04 21:39:09 +0000
commitd2eae2a2999de61ddb494780f2477f7f7569b804 (patch)
treec5d3c8a6faedc72c2d778fa3875ef87e47f88801 /source3/nsswitch
parentf7832e935f99ade0c764e063bb06e5ca36dd0bee (diff)
downloadsamba-d2eae2a2999de61ddb494780f2477f7f7569b804.tar.gz
samba-d2eae2a2999de61ddb494780f2477f7f7569b804.tar.bz2
samba-d2eae2a2999de61ddb494780f2477f7f7569b804.zip
merge native_mode flag in winbindd_domain struct from app-head
(This used to be commit dd948a302ad6bd4307ecdfb10510e12185150eae)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd.h1
-rw-r--r--source3/nsswitch/winbindd_cm.c54
-rw-r--r--source3/nsswitch/winbindd_util.c11
3 files changed, 61 insertions, 5 deletions
diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h
index dd92ecefe6..4ca59ff1cc 100644
--- a/source3/nsswitch/winbindd.h
+++ b/source3/nsswitch/winbindd.h
@@ -90,6 +90,7 @@ struct winbindd_domain {
fstring name; /* Domain name */
fstring alt_name; /* alt Domain name (if any) */
DOM_SID sid; /* SID for this domain */
+ BOOL native_mode; /* is this a win2k domain in native mode ? */
/* Lookup methods for this domain (LDAP or RPC) */
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index 313b9da1bb..91ab5b209d 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -384,7 +384,7 @@ static void add_failed_connection_entry(struct winbindd_cm_conn *new_conn,
/* Open a connction to the remote server, cache failures for 30 seconds */
-static NTSTATUS cm_open_connection(const char *domain,const char *pipe_name,
+static NTSTATUS cm_open_connection(const char *domain, const iont pipe_index,
struct winbindd_cm_conn *new_conn)
{
struct failed_connection_cache *fcc;
@@ -396,7 +396,7 @@ static NTSTATUS cm_open_connection(const char *domain,const char *pipe_name,
ZERO_STRUCT(dc_ip);
fstrcpy(new_conn->domain, domain);
- fstrcpy(new_conn->pipe_name, pipe_name);
+ fstrcpy(new_conn->pipe_name, get_pipe_name_from_index(pipe_index));
/* Look for a domain controller for this domain. Negative results
are cached so don't bother applying the caching for this
@@ -460,7 +460,7 @@ static NTSTATUS cm_open_connection(const char *domain,const char *pipe_name,
return result;
}
- if (!cli_nt_session_open (new_conn->cli, get_pipe_index(pipe_name))) {
+ if ( !cli_nt_session_open (new_conn->cli, pipe_index) ) {
result = NT_STATUS_PIPE_NOT_AVAILABLE;
add_failed_connection_entry(new_conn, result);
cli_shutdown(new_conn->cli);
@@ -533,7 +533,7 @@ static NTSTATUS get_connection_from_cache(const char *domain, const char *pipe_n
ZERO_STRUCTP(conn);
- if (!NT_STATUS_IS_OK(result = cm_open_connection(domain, pipe_name, conn))) {
+ if (!NT_STATUS_IS_OK(result = cm_open_connection(domain, get_pipe_index(pipe_name), conn))) {
DEBUG(3, ("Could not open a connection to %s for %s (%s)\n",
domain, pipe_name, nt_errstr(result)));
SAFE_FREE(conn);
@@ -546,6 +546,52 @@ static NTSTATUS get_connection_from_cache(const char *domain, const char *pipe_n
return NT_STATUS_OK;
}
+
+/**********************************************************************************
+**********************************************************************************/
+
+BOOL cm_check_for_native_mode_win2k( const char *domain )
+{
+ NTSTATUS result;
+ struct winbindd_cm_conn conn;
+ DS_DOMINFO_CTR ctr;
+ BOOL ret = False;
+
+ ZERO_STRUCT( conn );
+ ZERO_STRUCT( ctr );
+
+
+ if ( !NT_STATUS_IS_OK(result = cm_open_connection(domain, PI_LSARPC_DS, &conn)) )
+ {
+ DEBUG(3, ("cm_check_for_native_mode_win2k: Could not open a connection to %s for PIPE_LSARPC (%s)\n",
+ domain, nt_errstr(result)));
+ return False;
+ }
+
+ if ( conn.cli ) {
+ if ( !NT_STATUS_IS_OK(cli_ds_getprimarydominfo( conn.cli,
+ conn.cli->mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr)) )
+ {
+ ret = False;
+ goto done;
+ }
+ }
+
+ if ( (ctr.basic->flags & DSROLE_PRIMARY_DS_RUNNING)
+ && !(ctr.basic->flags & DSROLE_PRIMARY_DS_MIXED_MODE) )
+ {
+ ret = True;
+ }
+
+done:
+ if ( conn.cli )
+ cli_shutdown( conn.cli );
+
+ return ret;
+}
+
+
+
/* Return a LSA policy handle on a domain */
CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c
index 2016c27881..005b1609b6 100644
--- a/source3/nsswitch/winbindd_util.c
+++ b/source3/nsswitch/winbindd_util.c
@@ -73,6 +73,7 @@ void free_domain_list(void)
}
}
+
/* Add a trusted domain to our list of domains */
static struct winbindd_domain *add_trusted_domain(const char *domain_name, const char *alt_name,
struct winbindd_methods *methods,
@@ -116,12 +117,20 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const
}
}
- domain->methods = methods;
+ domain->methods = methods;
domain->sequence_number = DOM_SEQUENCE_NONE;
domain->last_seq_check = 0;
if (sid) {
sid_copy(&domain->sid, sid);
}
+
+ /* see if this is a native mode win2k domain, but only for our own domain */
+
+ if ( strequal( lp_workgroup(), domain_name) ) {
+ domain->native_mode = cm_check_for_native_mode_win2k( domain_name );
+ DEBUG(5,("add_trusted_domain: %s is a %s mode domain\n", domain_name,
+ domain->native_mode ? "native" : "mixed" ));
+ }
/* Link to domain list */
DLIST_ADD(_domain_list, domain);