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

mimir at samba.org mimir at samba.org
Tue Sep 19 00:23:55 GMT 2006


Author: mimir
Date: 2006-09-19 00:23:55 +0000 (Tue, 19 Sep 2006)
New Revision: 18655

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

Log:
add more fields and better handle the error case where fields
setting routine don't know how to do that (and user info level
is invalid).


rafal


Modified:
   branches/SAMBA_4_0/source/libnet/userman.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/userman.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/userman.c	2006-09-19 00:12:11 UTC (rev 18654)
+++ branches/SAMBA_4_0/source/libnet/userman.c	2006-09-19 00:23:55 UTC (rev 18655)
@@ -612,6 +612,39 @@
 				return s->change.fields;
 			}
 
+		} else if (s->change.fields & USERMOD_FIELD_LAST_LOGON) {
+			*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;
+			}
+		
+		} else if (s->change.fields & USERMOD_FIELD_LAST_LOGOFF) {
+			*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;
+			}
+
+		} else if (s->change.fields & USERMOD_FIELD_LAST_PASS_CHG) {
+			*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;
+			}
+
 		} else if (s->change.fields & USERMOD_FIELD_LOGON_SCRIPT) {
 			*level = 11;
 			i->info11.logon_script.string = s->change.logon_script;
@@ -624,6 +657,28 @@
 
 			s->change.fields ^= USERMOD_FIELD_PROFILE_PATH;
 
+		} else if (s->change.fields & USERMOD_FIELD_HOME_DIRECTORY) {
+			*level = 3;
+			
+			if (s->stage == USERMOD_QUERY) {
+				i->info3.home_directory.string = s->change.home_directory;
+				s->change.fields ^= USERMOD_FIELD_HOME_DIRECTORY;
+			} else {
+				s->stage = USERMOD_QUERY;
+				return s->change.fields;
+			}
+
+		} else if (s->change.fields & USERMOD_FIELD_HOME_DRIVE) {
+			*level = 3;
+
+			if (s->stage == USERMOD_QUERY) {
+				i->info3.home_drive.string = s->change.home_drive;
+				s->change.fields ^= USERMOD_FIELD_HOME_DRIVE;
+			} else {
+				s->stage = USERMOD_QUERY;
+				return s->change.fields;
+			}
+
 		} else if (s->change.fields & USERMOD_FIELD_ACCT_EXPIRY) {
 			*level = 17;
 			i->info17.acct_expiry = timeval_to_nttime(s->change.acct_expiry);
@@ -638,7 +693,7 @@
 		}
 	}
 
-	/* We're going to be back here again soon unless all fields have been set */
+	/* We're going to be here back again soon unless all fields have been set */
 	if (s->change.fields) {
 		s->stage = USERMOD_OPEN;
 	} else {
@@ -656,7 +711,9 @@
 			     struct usermod_state *s)
 {
 	union samr_UserInfo *i = &s->info;
-	uint16_t level;
+	/* set the level to invalid value, so that unless setfields routine 
+	   gives it a valid value we report the error correctly */
+	uint16_t level = 27;
 
 	c->status = dcerpc_ndr_request_recv(s->req);
 	NT_STATUS_NOT_OK_RETURN(c->status);
@@ -664,6 +721,13 @@
 	/* prepare UserInfo level and data based on bitmask field */
 	s->change.fields = usermod_setfields(s, &level, i);
 
+	if (level > 26) {
+		/* apparently there's a field that the setfields routine
+		   does not know how to set */
+		c->state = COMPOSITE_STATE_ERROR;
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
 	/* If some specific level is used to set user account data and the change
 	   itself does not cover all fields then we need to query the user info
 	   first, right before changing the data. Otherwise we could set required



More information about the samba-cvs mailing list