svn commit: samba r19024 - in branches/SAMBA_4_0/source/libnet: .

mimir at samba.org mimir at samba.org
Mon Oct 2 05:53:46 GMT 2006


Author: mimir
Date: 2006-10-02 05:53:45 +0000 (Mon, 02 Oct 2006)
New Revision: 19024

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19024

Log:
remove read-only and policy dependent fields and flags
from user modify routines.


rafal


Modified:
   branches/SAMBA_4_0/source/libnet/libnet_user.c
   branches/SAMBA_4_0/source/libnet/libnet_user.h
   branches/SAMBA_4_0/source/libnet/userinfo.c
   branches/SAMBA_4_0/source/libnet/userman.c
   branches/SAMBA_4_0/source/libnet/userman.h


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet_user.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_user.c	2006-10-02 05:52:42 UTC (rev 19023)
+++ branches/SAMBA_4_0/source/libnet/libnet_user.c	2006-10-02 05:53:45 UTC (rev 19024)
@@ -569,21 +569,6 @@
 	/* profile path change */
 	SET_FIELD_LSA_STRING(r->in, user, mod, profile_path, USERMOD_FIELD_PROFILE_PATH);
 
-	/* allow password change time */
-	SET_FIELD_NTTIME(r->in, user, mod, allow_password_change, USERMOD_FIELD_ALLOW_PASS_CHG);
-
-	/* force password change time */
-	SET_FIELD_NTTIME(r->in, user, mod, force_password_change, USERMOD_FIELD_FORCE_PASS_CHG);
-
-	/* last logon change time */
-	SET_FIELD_NTTIME(r->in, user, mod, last_logon, USERMOD_FIELD_LAST_LOGON);
-
-	/* last logoff change time */
-	SET_FIELD_NTTIME(r->in, user, mod, last_logoff, USERMOD_FIELD_LAST_LOGOFF);
-
-	/* last password change time */
-	SET_FIELD_NTTIME(r->in, user, mod, last_password_change, USERMOD_FIELD_LAST_PASS_CHG);
-
 	/* account expiry change */
 	SET_FIELD_NTTIME(r->in, user, mod, acct_expiry, USERMOD_FIELD_ACCT_EXPIRY);
 
@@ -629,6 +614,7 @@
 struct user_info_state {
 	struct libnet_context *ctx;
 	const char *domain_name;
+	const char *user_name;
 	struct libnet_LookupName lookup;
 	struct libnet_DomainOpen domopen;
 	struct libnet_rpc_userinfo userinfo;
@@ -639,7 +625,7 @@
 
 
 static void continue_name_found(struct composite_context *ctx);
-static void continue_domain_opened(struct composite_context *ctx);
+static void continue_domain_open_info(struct composite_context *ctx);
 static void continue_info_received(struct composite_context *ctx);
 
 
@@ -650,6 +636,7 @@
 {
 	struct composite_context *c;
 	struct user_info_state *s;
+	struct composite_context *prereq_ctx;
 	struct composite_context *lookup_req;
 
 	c = composite_create(mem_ctx, ctx->event_ctx);
@@ -663,9 +650,14 @@
 	s->monitor_fn = monitor;
 	s->ctx = ctx;
 	s->domain_name = talloc_strdup(c, r->in.domain_name);
+	s->user_name = talloc_strdup(c, r->in.user_name);
 
+	prereq_ctx = domain_opened(ctx, s->domain_name, c, &s->domopen,
+				   continue_domain_open_info, monitor);
+	if (prereq_ctx) return prereq_ctx;
+
 	s->lookup.in.domain_name = s->domain_name;
-	s->lookup.in.name        = talloc_strdup(c, r->in.user_name);
+	s->lookup.in.name        = s->user_name;
 
 	lookup_req = libnet_LookupName_send(ctx, c, &s->lookup, s->monitor_fn);
 	if (composite_nomem(lookup_req, c)) return c;
@@ -675,35 +667,32 @@
 }
 
 
-static void continue_name_found(struct composite_context *ctx)
+static void continue_domain_open_info(struct composite_context *ctx)
 {
 	struct composite_context *c;
 	struct user_info_state *s;
-	struct composite_context *domopen_req;
+	struct composite_context *lookup_req;
+	struct monitor_msg msg;
 
 	c = talloc_get_type(ctx->async.private_data, struct composite_context);
 	s = talloc_get_type(c->private_data, struct user_info_state);
 
-	c->status = libnet_LookupName_recv(ctx, c, &s->lookup);
+	c->status = libnet_DomainOpen_recv(ctx, s->ctx, c, &s->domopen);
 	if (!composite_is_ok(c)) return;
+	
+	if (s->monitor_fn) s->monitor_fn(&msg);
 
-	if (s->lookup.out.sid_type != SID_NAME_USER) {
-		composite_error(c, NT_STATUS_NO_SUCH_USER);
-		return;
-	}
+	s->lookup.in.domain_name = s->domain_name;
+	s->lookup.in.name        = s->user_name;
 
-	s->domopen.in.type = DOMAIN_SAMR;
-	s->domopen.in.domain_name = s->domain_name;
-	s->domopen.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-
-	domopen_req = libnet_DomainOpen_send(s->ctx, &s->domopen, s->monitor_fn);
-	if (composite_nomem(domopen_req, c)) return;
+	lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
+	if (composite_nomem(lookup_req, c)) return;
 	
-	composite_continue(c, domopen_req, continue_domain_opened, c);
+	composite_continue(c, lookup_req, continue_rpc_userinfo, c);
 }
 
 
-static void continue_domain_opened(struct composite_context *ctx)
+static void continue_name_found(struct composite_context *ctx)
 {
 	struct composite_context *c;
 	struct user_info_state *s;
@@ -712,9 +701,14 @@
 	c = talloc_get_type(ctx->async.private_data, struct composite_context);
 	s = talloc_get_type(c->private_data, struct user_info_state);
 
-	c->status = libnet_DomainOpen_recv(ctx, s->ctx, c, &s->domopen);
+	c->status = libnet_LookupName_recv(ctx, c, &s->lookup);
 	if (!composite_is_ok(c)) return;
 
+	if (s->lookup.out.sid_type != SID_NAME_USER) {
+		composite_error(c, NT_STATUS_NO_SUCH_USER);
+		return;
+	}
+
 	s->userinfo.in.domain_handle = s->ctx->samr.handle;
 	s->userinfo.in.sid = s->lookup.out.sidstr;
 	s->userinfo.in.level = 21;

Modified: branches/SAMBA_4_0/source/libnet/libnet_user.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_user.h	2006-10-02 05:52:42 UTC (rev 19023)
+++ branches/SAMBA_4_0/source/libnet/libnet_user.h	2006-10-02 05:53:45 UTC (rev 19024)
@@ -57,8 +57,6 @@
 		struct timeval *acct_expiry;
 		struct timeval *allow_password_change;
 		struct timeval *force_password_change;
-		struct timeval *last_logon;
-		struct timeval *last_logoff;
 		struct timeval *last_password_change;
 		uint32_t acct_flags;
 	} in;

Modified: branches/SAMBA_4_0/source/libnet/userinfo.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/userinfo.c	2006-10-02 05:52:42 UTC (rev 19023)
+++ branches/SAMBA_4_0/source/libnet/userinfo.c	2006-10-02 05:53:45 UTC (rev 19024)
@@ -104,7 +104,7 @@
 	/* receive samr_OpenUser reply */
 	c->status = dcerpc_ndr_request_recv(s->req);
 	NT_STATUS_NOT_OK_RETURN(c->status);
-
+	
 	/* prepare parameters for QueryUserInfo call */
 	s->queryuserinfo.in.user_handle = &s->user_handle;
 	s->queryuserinfo.in.level       = s->level;
@@ -134,6 +134,9 @@
 	c->status = dcerpc_ndr_request_recv(s->req);
 	NT_STATUS_NOT_OK_RETURN(c->status);
 
+	/* check if queryuser itself went ok */
+	NT_STATUS_NOT_OK_RETURN(s->queryuserinfo.out.result);
+
 	s->info = talloc_steal(s, s->queryuserinfo.out.info);
 	
 	/* prepare arguments for Close call */

Modified: branches/SAMBA_4_0/source/libnet/userman.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/userman.c	2006-10-02 05:52:42 UTC (rev 19023)
+++ branches/SAMBA_4_0/source/libnet/userman.c	2006-10-02 05:53:45 UTC (rev 19024)
@@ -565,7 +565,6 @@
 		i->info7.account_name.string = s->change.account_name;
 		
 		s->change.fields ^= USERMOD_FIELD_ACCOUNT_NAME;
-		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_FULL_NAME) &&
@@ -581,8 +580,7 @@
 		*level = 13;
 		i->info13.description.string = s->change.description;
 		
-		s->change.fields ^= USERMOD_FIELD_DESCRIPTION;
-		
+		s->change.fields ^= USERMOD_FIELD_DESCRIPTION;		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_COMMENT) &&
@@ -599,88 +597,14 @@
 			s->stage = USERMOD_QUERY;
 			return s->change.fields;
 		}
-		
 	}
 
-	if ((s->change.fields & USERMOD_FIELD_ALLOW_PASS_CHG) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
-		
-		if (s->stage == USERMOD_QUERY) {
-			i->info3.allow_password_change = timeval_to_nttime(s->change.allow_password_change);
-			s->change.fields ^= USERMOD_FIELD_ALLOW_PASS_CHG;
-			
-		} else {
-			s->stage = USERMOD_QUERY;
-			return s->change.fields;
-		}
-
-	}
-	
-	if ((s->change.fields & USERMOD_FIELD_FORCE_PASS_CHG) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
-
-		if (s->stage == USERMOD_QUERY) {
-			i->info3.force_password_change = timeval_to_nttime(s->change.force_password_change);
-			s->change.fields ^= USERMOD_FIELD_FORCE_PASS_CHG;
-			
-		} else {
-			s->stage = USERMOD_QUERY;
-			return s->change.fields;
-		}
-		
-	}
-
-	if ((s->change.fields & USERMOD_FIELD_LAST_LOGON) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
-		
-		if (s->stage == USERMOD_QUERY) {
-			i->info3.last_logon = timeval_to_nttime(s->change.last_logon);
-			s->change.fields ^= USERMOD_FIELD_LAST_LOGON;
-		} else {
-			s->stage = USERMOD_QUERY;
-			return s->change.fields;
-		}
-		
-	}
-
-	if ((s->change.fields & USERMOD_FIELD_LAST_LOGOFF) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
-		
-		if (s->stage == USERMOD_QUERY) {
-			i->info3.last_logoff = timeval_to_nttime(s->change.last_logoff);
-			s->change.fields ^= USERMOD_FIELD_LAST_LOGOFF;
-		} else {
-			s->stage = USERMOD_QUERY;
-			return s->change.fields;
-		}
-
-	}
-	
-	if ((s->change.fields & USERMOD_FIELD_LAST_PASS_CHG) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
-		
-		if (s->stage == USERMOD_QUERY) {
-			i->info3.last_password_change = timeval_to_nttime(s->change.last_password_change);
-			s->change.fields ^= USERMOD_FIELD_LAST_PASS_CHG;
-		} else {
-			s->stage = USERMOD_QUERY;
-			return s->change.fields;
-		}
-		
-	}
-	
 	if ((s->change.fields & USERMOD_FIELD_LOGON_SCRIPT) &&
 	    (*level == 0 || *level == 11)) {
 		*level = 11;
 		i->info11.logon_script.string = s->change.logon_script;
 		
 		s->change.fields ^= USERMOD_FIELD_LOGON_SCRIPT;
-		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_PROFILE_PATH) &&
@@ -689,35 +613,32 @@
 		i->info12.profile_path.string = s->change.profile_path;
 		
 		s->change.fields ^= USERMOD_FIELD_PROFILE_PATH;
-		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_HOME_DIRECTORY) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
+	    (*level == 0 || *level == 10)) {
+		*level = 10;
 		
 		if (s->stage == USERMOD_QUERY) {
-			i->info3.home_directory.string = s->change.home_directory;
+			i->info10.home_directory.string = s->change.home_directory;
 			s->change.fields ^= USERMOD_FIELD_HOME_DIRECTORY;
 		} else {
 			s->stage = USERMOD_QUERY;
 			return s->change.fields;
 		}
-		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_HOME_DRIVE) &&
-	    (*level == 0 || *level == 3)) {
-		*level = 3;
+	    (*level == 0 || *level == 10)) {
+		*level = 10;
 		
 		if (s->stage == USERMOD_QUERY) {
-			i->info3.home_drive.string = s->change.home_drive;
+			i->info10.home_drive.string = s->change.home_drive;
 			s->change.fields ^= USERMOD_FIELD_HOME_DRIVE;
 		} else {
 			s->stage = USERMOD_QUERY;
 			return s->change.fields;
 		}
-		
 	}
 	
 	if ((s->change.fields & USERMOD_FIELD_ACCT_EXPIRY) &&
@@ -726,7 +647,6 @@
 		i->info17.acct_expiry = timeval_to_nttime(s->change.acct_expiry);
 		
 		s->change.fields ^= USERMOD_FIELD_ACCT_EXPIRY;
-		
 	}
 
 	if ((s->change.fields & USERMOD_FIELD_ACCT_FLAGS) &&
@@ -855,6 +775,8 @@
 	c->status = dcerpc_ndr_request_recv(s->req);
 	NT_STATUS_NOT_OK_RETURN(c->status);
 
+	NT_STATUS_NOT_OK_RETURN(s->setuser.out.result);
+
 	if (s->change.fields == 0) {
 		/* all fields have been set - we're done */
 		c->state = COMPOSITE_STATE_DONE;

Modified: branches/SAMBA_4_0/source/libnet/userman.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/userman.h	2006-10-02 05:52:42 UTC (rev 19023)
+++ branches/SAMBA_4_0/source/libnet/userman.h	2006-10-02 05:53:45 UTC (rev 19024)
@@ -56,16 +56,10 @@
 #define USERMOD_FIELD_HOME_DRIVE      ( 0x00001000 )
 #define USERMOD_FIELD_LOGON_HOURS     ( 0x00002000 )
 #define USERMOD_FIELD_ACCT_EXPIRY     ( 0x00004000 )
-#define USERMOD_FIELD_ALLOW_PASS_CHG  ( 0x00008000 )
-#define USERMOD_FIELD_FORCE_PASS_CHG  ( 0x00010000 )
-#define USERMOD_FIELD_LAST_LOGON      ( 0x00020000 )
-#define USERMOD_FIELD_LAST_LOGOFF     ( 0x00040000 )
-#define USERMOD_FIELD_LAST_PASS_CHG   ( 0x00080000 )
 #define USERMOD_FIELD_ACCT_FLAGS      ( 0x00100000 )
 #define USERMOD_FIELD_PARAMETERS      ( 0x00200000 )
 #define USERMOD_FIELD_COUNTRY_CODE    ( 0x00400000 )
 #define USERMOD_FIELD_CODE_PAGE       ( 0x00800000 )
-#define USERMOD_FIELD_ACCT_FLAGS      ( 0x00100000 )
 
 struct libnet_rpc_usermod {
 	struct {



More information about the samba-cvs mailing list