svn commit: samba r17448 - in branches/SAMBA_4_0/source/libnet: .
mimir at samba.org
mimir at samba.org
Mon Aug 7 20:29:18 GMT 2006
Author: mimir
Date: 2006-08-07 20:29:18 +0000 (Mon, 07 Aug 2006)
New Revision: 17448
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17448
Log:
Define macros to set fields in api function modifying user account.
rafal
Modified:
branches/SAMBA_4_0/source/libnet/libnet_user.c
branches/SAMBA_4_0/source/libnet/libnet_user.h
Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet_user.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_user.c 2006-08-07 20:28:09 UTC (rev 17447)
+++ branches/SAMBA_4_0/source/libnet/libnet_user.c 2006-08-07 20:29:18 UTC (rev 17448)
@@ -543,42 +543,39 @@
user = &info->out.info.info21;
mod->fields = 0; /* reset flag field before setting individual flags */
- /*
- * account name change
- */
- if (r->in.account_name != NULL &&
- !strequal_w(user->account_name.string, r->in.account_name)) {
+ /* account name change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, account_name, USERMOD_FIELD_ACCOUNT_NAME);
- mod->account_name = talloc_strdup(mem_ctx, r->in.account_name);
- if (mod->account_name == NULL) return NT_STATUS_NO_MEMORY;
+ /* full name change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, full_name, USERMOD_FIELD_FULL_NAME);
- mod->fields |= USERMOD_FIELD_ACCOUNT_NAME;
- }
+ /* description change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, comment, USERMOD_FIELD_DESCRIPTION);
- /*
- * full name change
- */
- if (r->in.full_name != NULL &&
- !strequal_w(user->full_name.string, r->in.full_name)) {
-
- mod->full_name = talloc_strdup(mem_ctx, r->in.full_name);
- if (mod->full_name == NULL) return NT_STATUS_NO_MEMORY;
+ /* comment change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, comment, USERMOD_FIELD_COMMENT);
- mod->fields |= USERMOD_FIELD_FULL_NAME;
- }
+ /* home directory change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, home_directory, USERMOD_FIELD_HOME_DIRECTORY);
- /*
- * description change
- */
- if (r->in.description != NULL &&
- !strequal_w(user->description.string, r->in.description)) {
+ /* home drive change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, home_drive, USERMOD_FIELD_HOME_DRIVE);
- mod->description = talloc_strdup(mem_ctx, r->in.description);
- if (mod->description == NULL) return NT_STATUS_NO_MEMORY;
+ /* logon script change */
+ SET_FIELD_LSA_STRING(r->in, user, mod, logon_script, USERMOD_FIELD_LOGON_SCRIPT);
- mod->fields |= USERMOD_FIELD_DESCRIPTION;
- }
+ /* 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);
+
+ /* account expiry change */
+ SET_FIELD_NTTIME(r->in, user, mod, acct_expiry, USERMOD_FIELD_ACCT_EXPIRY);
+
return NT_STATUS_OK;
}
Modified: branches/SAMBA_4_0/source/libnet/libnet_user.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_user.h 2006-08-07 20:28:09 UTC (rev 17447)
+++ branches/SAMBA_4_0/source/libnet/libnet_user.h 2006-08-07 20:29:18 UTC (rev 17448)
@@ -49,15 +49,40 @@
const char *account_name;
const char *full_name;
const char *description;
+ const char *home_directory;
+ const char *home_drive;
const char *comment;
const char *logon_script;
const char *profile_path;
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;
struct {
const char *error_string;
} out;
};
+
+
+#define SET_FIELD_LSA_STRING(new, current, mod, field, flag) \
+ if (new.field != NULL && \
+ !strequal_w(current->field.string, new.field)) { \
+ \
+ mod->field = talloc_strdup(mem_ctx, new.field); \
+ if (mod->field == NULL) return NT_STATUS_NO_MEMORY; \
+ \
+ mod->fields |= flag; \
+ }
+
+#define SET_FIELD_NTTIME(new, current, mod, field, flag) \
+ if (new.field != 0) { \
+ NTTIME newval = timeval_to_nttime(new.field); \
+ if (newval != current->field) { \
+ mod->field = talloc_memdup(mem_ctx, new.field, sizeof(*new.field)); \
+ mod->fields |= flag; \
+ } \
+ }
More information about the samba-cvs
mailing list