[SCM] Samba Shared Repository - branch master updated -
bed91c0e463ed425288f7b4223739108c1fced45
Günther Deschner
gd at samba.org
Thu Nov 27 17:28:39 GMT 2008
The branch, master has been updated
via bed91c0e463ed425288f7b4223739108c1fced45 (commit)
via e09f658be72b6304e541da02dce843de79488d1c (commit)
from 5aebfd9086eead8aad526827661ab10679414891 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bed91c0e463ed425288f7b4223739108c1fced45
Author: Günther Deschner <gd at samba.org>
Date: Tue Nov 25 12:21:37 2008 +0100
s3-samr: add support for _samr_QueryUserInfo level 5.
Guenther
commit e09f658be72b6304e541da02dce843de79488d1c
Author: Günther Deschner <gd at samba.org>
Date: Tue Nov 25 12:18:39 2008 +0100
s3-samr: add init_samr_user_info5.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 19 +++++++
source3/rpc_client/init_samr.c | 47 ++++++++++++++++
source3/rpc_server/srv_samr_nt.c | 108 ++++++++++++++++++++++++++++++++++++++
3 files changed, 174 insertions(+), 0 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a026723..73be87b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5644,6 +5644,25 @@ void init_samr_alias_info1(struct samr_AliasInfoAll *r,
const char *description);
void init_samr_alias_info3(struct lsa_String *r,
const char *description);
+void init_samr_user_info5(struct samr_UserInfo5 *r,
+ const char *account_name,
+ const char *full_name,
+ uint32_t rid,
+ uint32_t primary_gid,
+ const char *home_directory,
+ const char *home_drive,
+ const char *logon_script,
+ const char *profile_path,
+ const char *description,
+ const char *workstations,
+ NTTIME last_logon,
+ NTTIME last_logoff,
+ struct samr_LogonHours logon_hours,
+ uint16_t bad_password_count,
+ uint16_t logon_count,
+ NTTIME last_password_change,
+ NTTIME acct_expiry,
+ uint32_t acct_flags);
void init_samr_user_info7(struct samr_UserInfo7 *r,
const char *account_name);
void init_samr_user_info9(struct samr_UserInfo9 *r,
diff --git a/source3/rpc_client/init_samr.c b/source3/rpc_client/init_samr.c
index 283be0d..43809c0 100644
--- a/source3/rpc_client/init_samr.c
+++ b/source3/rpc_client/init_samr.c
@@ -252,6 +252,53 @@ void init_samr_alias_info3(struct lsa_String *r,
}
/*******************************************************************
+ inits a samr_UserInfo5 structure.
+********************************************************************/
+
+void init_samr_user_info5(struct samr_UserInfo5 *r,
+ const char *account_name,
+ const char *full_name,
+ uint32_t rid,
+ uint32_t primary_gid,
+ const char *home_directory,
+ const char *home_drive,
+ const char *logon_script,
+ const char *profile_path,
+ const char *description,
+ const char *workstations,
+ NTTIME last_logon,
+ NTTIME last_logoff,
+ struct samr_LogonHours logon_hours,
+ uint16_t bad_password_count,
+ uint16_t logon_count,
+ NTTIME last_password_change,
+ NTTIME acct_expiry,
+ uint32_t acct_flags)
+{
+ DEBUG(5, ("init_samr_user_info5\n"));
+
+ init_lsa_String(&r->account_name, account_name);
+ init_lsa_String(&r->full_name, full_name);
+ r->rid = rid;
+ r->primary_gid = primary_gid;
+ init_lsa_String(&r->home_directory, home_directory);
+ init_lsa_String(&r->home_drive, home_drive);
+ init_lsa_String(&r->logon_script, logon_script);
+ init_lsa_String(&r->profile_path, profile_path);
+ init_lsa_String(&r->description, description);
+ init_lsa_String(&r->workstations, workstations);
+ r->last_logon = last_logon;
+ r->last_logoff = last_logoff;
+ r->logon_hours = logon_hours;
+ r->bad_password_count = bad_password_count;
+ r->logon_count = logon_count;
+ r->last_password_change = last_password_change;
+ r->acct_expiry = acct_expiry;
+ r->acct_flags = acct_flags;
+}
+
+
+/*******************************************************************
inits a samr_UserInfo7 structure.
********************************************************************/
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index ba9d911..0623dfb 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2248,6 +2248,108 @@ static NTSTATUS init_samr_parameters_string(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+static NTSTATUS get_user_info_5(TALLOC_CTX *mem_ctx,
+ struct samr_UserInfo5 *r,
+ DOM_SID *user_sid,
+ DOM_SID *domain_sid)
+{
+ struct samu *pw = NULL;
+ bool ret;
+ const DOM_SID *sid_user, *sid_group;
+ uint32_t rid, primary_gid;
+ NTTIME last_logon, last_logoff, last_password_change,
+ acct_expiry;
+ const char *account_name, *full_name, *home_directory, *home_drive,
+ *logon_script, *profile_path, *description,
+ *workstations, *comment;
+ struct samr_LogonHours logon_hours;
+
+ ZERO_STRUCTP(r);
+
+ if (!(pw = samu_new(mem_ctx))) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ become_root();
+ ret = pdb_getsampwsid(pw, user_sid);
+ unbecome_root();
+
+ if (ret == False) {
+ DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid)));
+ TALLOC_FREE(pw);
+ return NT_STATUS_NO_SUCH_USER;
+ }
+
+ samr_clear_sam_passwd(pw);
+
+ DEBUG(3,("User:[%s]\n", pdb_get_username(pw)));
+
+ sid_user = pdb_get_user_sid(pw);
+
+ if (!sid_peek_check_rid(domain_sid, sid_user, &rid)) {
+ DEBUG(0, ("get_user_info_5: User %s has SID %s, \nwhich conflicts with "
+ "the domain sid %s. Failing operation.\n",
+ pdb_get_username(pw), sid_string_dbg(sid_user),
+ sid_string_dbg(domain_sid)));
+ TALLOC_FREE(pw);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ become_root();
+ sid_group = pdb_get_group_sid(pw);
+ unbecome_root();
+
+ if (!sid_peek_check_rid(domain_sid, sid_group, &primary_gid)) {
+ DEBUG(0, ("get_user_info_5: User %s has Primary Group SID %s, \n"
+ "which conflicts with the domain sid %s. Failing operation.\n",
+ pdb_get_username(pw), sid_string_dbg(sid_group),
+ sid_string_dbg(domain_sid)));
+ TALLOC_FREE(pw);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ unix_to_nt_time(&last_logon, pdb_get_logon_time(pw));
+ unix_to_nt_time(&last_logoff, pdb_get_logoff_time(pw));
+ unix_to_nt_time(&acct_expiry, pdb_get_kickoff_time(pw));
+ unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(pw));
+
+ account_name = talloc_strdup(mem_ctx, pdb_get_username(pw));
+ full_name = talloc_strdup(mem_ctx, pdb_get_fullname(pw));
+ home_directory = talloc_strdup(mem_ctx, pdb_get_homedir(pw));
+ home_drive = talloc_strdup(mem_ctx, pdb_get_dir_drive(pw));
+ logon_script = talloc_strdup(mem_ctx, pdb_get_logon_script(pw));
+ profile_path = talloc_strdup(mem_ctx, pdb_get_profile_path(pw));
+ description = talloc_strdup(mem_ctx, pdb_get_acct_desc(pw));
+ workstations = talloc_strdup(mem_ctx, pdb_get_workstations(pw));
+ comment = talloc_strdup(mem_ctx, pdb_get_comment(pw));
+
+ logon_hours = get_logon_hours_from_pdb(mem_ctx, pw);
+
+ init_samr_user_info5(r,
+ account_name,
+ full_name,
+ rid,
+ primary_gid,
+ home_directory,
+ home_drive,
+ logon_script,
+ profile_path,
+ description,
+ workstations,
+ last_logon,
+ last_logoff,
+ logon_hours,
+ pdb_get_bad_password_count(pw),
+ pdb_get_logon_count(pw),
+ last_password_change,
+ acct_expiry,
+ pdb_get_acct_ctrl(pw));
+
+ TALLOC_FREE(pw);
+
+ return NT_STATUS_OK;
+}
+
/*************************************************************************
get_user_info_7. Safe. Only gives out account_name.
*************************************************************************/
@@ -2677,6 +2779,12 @@ NTSTATUS _samr_QueryUserInfo(pipes_struct *p,
DEBUG(5,("_samr_QueryUserInfo: user info level: %d\n", r->in.level));
switch (r->in.level) {
+ case 5:
+ status = get_user_info_5(p->mem_ctx, &user_info->info5, &info->sid, &domain_sid);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ break;
case 7:
status = get_user_info_7(p->mem_ctx, &user_info->info7, &info->sid);
if (!NT_STATUS_IS_OK(status)) {
--
Samba Shared Repository
More information about the samba-cvs
mailing list