diff options
author | Rafal Szczesniak <mimir@samba.org> | 2006-09-19 00:23:55 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:18:59 -0500 |
commit | 602b604599c6a7c5fd6e3f8b6b1de61045a173da (patch) | |
tree | 62343602fe14bb2dfeab30750b730a917e962cc5 | |
parent | cd9057a0bb90bef6d31051f176849b6a3543a376 (diff) | |
download | samba-602b604599c6a7c5fd6e3f8b6b1de61045a173da.tar.gz samba-602b604599c6a7c5fd6e3f8b6b1de61045a173da.tar.bz2 samba-602b604599c6a7c5fd6e3f8b6b1de61045a173da.zip |
r18655: 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
(This used to be commit a7564931a72069f5ddc86956bc573f448a3c99f7)
-rw-r--r-- | source4/libnet/userman.c | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c index 08b0a2f1e2..c565dde00a 100644 --- a/source4/libnet/userman.c +++ b/source4/libnet/userman.c @@ -612,6 +612,39 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level, 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 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level, 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 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level, } } - /* 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 @@ static NTSTATUS usermod_open(struct composite_context *c, 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 @@ static NTSTATUS usermod_open(struct composite_context *c, /* 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 |