1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

Remove SAM from 3.0 - it belongs in HEAD

(This used to be commit cda79af76a)
This commit is contained in:
Jelmer Vernooij 2002-10-29 21:23:15 +00:00
parent 11817b0780
commit 3df7c60f88
9 changed files with 0 additions and 3502 deletions

View File

@ -1,123 +0,0 @@
SAM API
NTSTATUS sam_get_sec_obj(NT_USER_TOKEN *access, DOM_SID *sid, SEC_DESC **sd)
NTSTATUS sam_set_sec_obj(NT_USER_TOKEN *access, DOM_SID *sid, SEC_DESC *sd)
NTSTATUS sam_lookup_name(NT_USER_TOKEN *access, DOM_SID *domain, char *name, DOM_SID **sid, uint32 *type)
NTSTATUS sam_lookup_sid(NT_USER_TOKEN *access, DOM_SID *sid, char **name, uint32 *type)
Domain API
NTSTATUS sam_update_domain(SAM_DOMAIN_HANDLE *domain)
NTSTATUS sam_enum_domains(NT_USER_TOKEN *access, int32 *domain_count, DOM_SID **domains, char **domain_names)
NTSTATUS sam_lookup_domain(NT_USER_TOKEN *access, char *domain, DOM_SID **domainsid)
NTSTATUS sam_get_domain_by_sid(NT_USER_TOKEN *access, uint32 access_desired, DOM_SID *domainsid, SAM_DOMAIN_HANDLE **domain)
User API
NTSTATUS sam_create_user(NT_USER_TOKEN *access, uint32 access_desired, SAM_USER_HANDLE **user)
NTSTATUS sam_add_user(SAM_USER_HANDLE *user)
NTSTATUS sam_update_user(SAM_USER_HANDLE *user)
NTSTATUS sam_delete_user(SAM_USER_HANDLE * user)
NTSTATUS sam_enum_users(NT_USER_TOKEN *access, DOM_SID *domain, int32 *user_count, SAM_USER_ENUM **users)
NTSTATUS sam_get_user_by_sid(NT_USER_TOKEN *access, uint32 access_desired, DOM_SID *usersid, SAM_USER_HANDLE **user)
NTSTATUS sam_get_user_by_name(NT_USER_TOKEN *access, uint32 access_desired, char *domain, char *name, SAM_USER_HANDLE **user)
Group API
NTSTATUS sam_create_group(NT_USER_TOKEN *access, uint32 access_desired, uint32 typ, SAM_GROUP_HANDLE **group)
NTSTATUS sam_add_group(SAM_GROUP_HANDLE *samgroup)
NTSTATUS sam_update_group(SAM_GROUP_HANDLE *samgroup)
NTSTATUS sam_delete_group(SAM_GROUP_HANDLE *groupsid)
NTSTATUS sam_enum_groups(NT_USER_TOKEN *access, DOM_SID *domainsid, uint32 typ, uint32 *groups_count, SAM_GROUP_ENUM **groups)
NTSTATUS sam_get_group_by_sid(NT_USER_TOKEN *access, uint32 access_desired, DOM_SID *groupsid, SAM_GROUP_HANDLE **group)
NTSTATUS sam_get_group_by_name(NT_USER_TOKEN *access, uint32 access_desired, char *domain, char *name, SAM_GROUP_HANDLE **group)
NTSTATUS sam_add_member_to_group(SAM_GROUP_HANDLE *group, SAM_GROUP_MEMBER *member)
NTSTATUS sam_delete_member_from_group(SAM_GROUP_HANDLE *group, SAM_GROUP_MEMBER *member)
NTSTATUS sam_enum_groupmembers(SAM_GROUP_HANLDE *group, uint32 *members_count, SAM_GROUP_MEMBER **members)
NTSTATUS sam_get_groups_of_user(SAM_USER_HANDLE *user, uint32 typ, uint32 *group_count, SAM_GROUP_ENUM **groups)
structures
typedef _SAM_GROUP_MEMBER {
DOM_SID sid;
BOOL group; /* specifies if it is a group or a user */
} SAM_GROUP_MEMBER
typedef struct sam_user_enum {
DOM_SID sid;
char *username;
char *full_name;
char *user_desc;
uint16 acc_ctrl;
} SAM_USER_ENUM;
typedef struct sam_group_enum {
DOM_SID sid;
char *groupname;
char *comment;
} SAM_GROUP_ENUM
NTSTATUS sam_get_domain_sid(SAM_DOMAIN_HANDLE *domain, DOM_SID **sid)
NTSTATUS sam_get_domain_num_users(SAM_DOMAIN_HANDLE *domain, uint32 *num_users)
NTSTATUS sam_get_domain_num_groups(SAM_DOMAIN_HANDLE *domain, uint32 *num_groups)
NTSTATUS sam_get_domain_num_aliases(SAM_DOMAIN_HANDLE *domain, uint32 *num_aliases)
NTSTATUS sam_{get,set}_domain_name(SAM_DOMAIN_HANDLE *domain, char **domain_name)
NTSTATUS sam_{get,set}_domain_server(SAM_DOMAIN_HANDLE *domain, char **server_name)
NTSTATUS sam_{get,set}_domain_max_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME *max_passwordage)
NTSTATUS sam_{get,set}_domain_min_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME *min_passwordage)
NTSTATUS sam_{get,set}_domain_lockout_duration(SAM_DOMAIN_HANDLE *domain, NTTIME *lockout_duration)
NTSTATUS sam_{get,set}_domain_reset_count(SAM_DOMAIN_HANDLE *domain, NTTIME *reset_lockout_count)
NTSTATUS sam_{get,set}_domain_min_pwdlength(SAM_DOMAIN_HANDLE *domain, uint16 *min_passwordlength)
NTSTATUS sam_{get,set}_domain_pwd_history(SAM_DOMAIN_HANDLE *domain, uin16 *password_history)
NTSTATUS sam_{get,set}_domain_lockout_count(SAM_DOMAIN_HANDLE *domain, uint16 *lockout_count)
NTSTATUS sam_{get,set}_domain_force_logoff(SAM_DOMAIN_HANDLE *domain, BOOL *force_logoff)
NTSTATUS sam_{get,set}_domain_login_pwdchange(SAM_DOMAIN_HANDLE *domain, BOOL *login_pwdchange)
NTSTATUS sam_get_user_sid(SAM_USER_HANDLE *user, DOM_SID **sid)
NTSTATUS sam_{get,set}_user_pgroup(SAM_USER_HANDLE *user, DOM_SID **pgroup)
NTSTATUS sam_{get,set}_user_name(SAM_USER_HANDLE *user, char **username)
NTSTATUS sam_{get,set}_user_fullname(SAM_USER_HANDLE *user, char** fullname)
NTSTATUS sam_{get,set}_user_description(SAM_USER_HANDLE *user, char **description)
NTSTATUS sam_{get,set}_user_home_dir(SAM_USER_HANDLE *user, char **home_dir)
NTSTATUS sam_{get,set}_user_dir_drive(SAM_USER_HANDLE *user, char **dir_drive)
NTSTATUS sam_{get,set}_user_logon_script(SAM_USER_HANDLE *user, char **logon_script)
NTSTATUS sam_{get,set}_user_profile_path(SAM_USER_HANDLE *user, char **profile_path)
NTSTATUS sam_{get,set}_user_workstations(SAM_USER_HANDLE *user, char **workstations)
NTSTATUS sam_{get,set}_user_munged_dial(SAM_USER_HANDLE *user, char **munged_dial)
NTSTATUS sam_{get,set}_user_lm_pwd(SAM_USER_HANDLE *user, DATA_BLOB *lm_pwd)
NTSTATUS sam_{get,set}_user_nt_pwd(SAM_USER_HANDLE *user, DATA_BLOB *nt_pwd)
NTSTATUS sam_{get,set}_user_plain_pwd(SAM_USER_HANDLE *user, DATA_BLOB *plaintext_pwd)
NTSTATUS sam_{get,set}_user_acct_ctrl(SAM_USER_HANDLE *user, uint16 *acct_ctrl)
NTSTATUS sam_{get,set}_user_logon_divs(SAM_USER_HANDLE *user, uint16 *logon_divs)
NTSTATUS sam_{get,set}_user_hours(SAM_USER_HANDLE *user, uint32 *hours_len, uint8 **hours)
NTSTATUS sam_{get,set}_user_logon_time(SAM_USER_HANDLE *user, NTTIME *logon_time)
NTSTATUS sam_{get,set}_user_logoff_time(SAM_USER_HANDLE *user, NTTIME *logoff_time)
NTSTATUS sam_{get,set}_user_kickoff_time(SAM_USER_HANDLE *user, NTTIME kickoff_time)
NTSTATUS sam_{get,set}_user_pwd_last_set(SAM_USER_HANDLE *user, NTTIME pwd_last_set)
NTSTATUS sam_{get,set}_user_pwd_can_change(SAM_USER_HANDLE *user, NTTIME pwd_can_change)
NTSTATUS sam_{get,set}_user_pwd_must_change(SAM_USER_HANDLE *user, NTTIME pwd_must_change)
NTSTATUS sam_{get,set}_user_unknown_1(SAM_USER_HANDLE *user, char **unknown_1)
NTSTATUS sam_{get,set}_user_unknown_2(SAM_USER_HANDLE *user, uint32 *unknown_2)
NTSTATUS sam_{get,set}_user_unknown_3(SAM_USER_HANDLE *user, uint32 *unknown_3)
NTSTATUS sam_{get,set}_user_unknown_4(SAM_USER_HANDLE *user, uint32 *unknown_4)
NTSTATUS sam_get_group_sid(SAM_GROUP_HANDLE *group, DOM_SID **sid)
NTSTATUS sam_get_group_typ(SAM_GROUP_HANDLE *group, uint32 *typ)
NTSTATUS sam_{get,set}_group_name(SAM_GROUP_HANDLE *group, char **group_name)
NTSTATUS sam_{get,set}_group_comment(SAM_GROUP_HANDLE *group, char **comment)
NTSTATUS sam_{get,set}_group_priv_set(SAM_GROUP_HANDLE *group, PRIVILEGE_SET *priv_set)

View File

@ -1,307 +0,0 @@
/*
Unix SMB/CIFS implementation.
Password and authentication handling
Copyright (C) Jeremy Allison 1996-2001
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
Copyright (C) Gerald (Jerry) Carter 2000-2001
Copyright (C) Andrew Bartlett 2001-2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
/************************************************************
Fill the SAM_ACCOUNT_HANDLE with default values.
***********************************************************/
static void sam_fill_default_account(SAM_ACCOUNT_HANDLE *account)
{
ZERO_STRUCT(account->private); /* Don't touch the talloc context */
/* Don't change these timestamp settings without a good reason.
They are important for NT member server compatibility. */
account->private.init_flag = FLAG_SAM_UNINIT;
/* FIXME: We should actually call get_nt_time_max() or sthng
* here */
unix_to_nt_time(&(account->private.logoff_time),get_time_t_max());
unix_to_nt_time(&(account->private.kickoff_time),get_time_t_max());
unix_to_nt_time(&(account->private.pass_must_change_time),get_time_t_max());
account->private.unknown_1 = 0x00ffffff; /* don't know */
account->private.logon_divs = 168; /* hours per week */
account->private.hours_len = 21; /* 21 times 8 bits = 168 */
memset(account->private.hours, 0xff, account->private.hours_len); /* available at all hours */
account->private.unknown_2 = 0x00000000; /* don't know */
account->private.unknown_3 = 0x000004ec; /* don't know */
}
static void destroy_sam_talloc(SAM_ACCOUNT_HANDLE **account)
{
if (*account) {
data_blob_clear_free(&((*account)->private.lm_pw));
data_blob_clear_free(&((*account)->private.nt_pw));
if((*account)->private.plaintext_pw!=NULL)
memset((*account)->private.plaintext_pw,'\0',strlen((*account)->private.plaintext_pw));
talloc_destroy((*account)->mem_ctx);
*account = NULL;
}
}
/**********************************************************************
Alloc memory and initialises a SAM_ACCOUNT_HANDLE on supplied mem_ctx.
***********************************************************************/
NTSTATUS sam_init_account_talloc(TALLOC_CTX *mem_ctx, SAM_ACCOUNT_HANDLE **account)
{
SMB_ASSERT(*account != NULL);
if (!mem_ctx) {
DEBUG(0,("sam_init_account_talloc: mem_ctx was NULL!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
*account=(SAM_ACCOUNT_HANDLE *)talloc(mem_ctx, sizeof(SAM_ACCOUNT_HANDLE));
if (*account==NULL) {
DEBUG(0,("sam_init_account_talloc: error while allocating memory\n"));
return NT_STATUS_NO_MEMORY;
}
(*account)->mem_ctx = mem_ctx;
(*account)->free_fn = NULL;
sam_fill_default_account(*account);
return NT_STATUS_OK;
}
/*************************************************************
Alloc memory and initialises a struct sam_passwd.
************************************************************/
NTSTATUS sam_init_account(SAM_ACCOUNT_HANDLE **account)
{
TALLOC_CTX *mem_ctx;
NTSTATUS nt_status;
mem_ctx = talloc_init_named("sam internal SAM_ACCOUNT_HANDLE allocation");
if (!mem_ctx) {
DEBUG(0,("sam_init_account: error while doing talloc_init()\n"));
return NT_STATUS_NO_MEMORY;
}
if (!NT_STATUS_IS_OK(nt_status = sam_init_account_talloc(mem_ctx, account))) {
talloc_destroy(mem_ctx);
return nt_status;
}
(*account)->free_fn = destroy_sam_talloc;
return NT_STATUS_OK;
}
/**
* Free the contents of the SAM_ACCOUNT_HANDLE, but not the structure.
*
* Also wipes the LM and NT hashes and plaintext password from
* memory.
*
* @param account SAM_ACCOUNT_HANDLE to free members of.
**/
static void sam_free_account_contents(SAM_ACCOUNT_HANDLE *account)
{
/* Kill off sensitive data. Free()ed by the
talloc mechinism */
data_blob_clear_free(&(account->private.lm_pw));
data_blob_clear_free(&(account->private.nt_pw));
if (account->private.plaintext_pw)
memset(account->private.plaintext_pw,'\0',strlen(account->private.plaintext_pw));
}
/************************************************************
Reset the SAM_ACCOUNT_HANDLE and free the NT/LM hashes.
***********************************************************/
NTSTATUS sam_reset_sam(SAM_ACCOUNT_HANDLE *account)
{
SMB_ASSERT(account != NULL);
sam_free_account_contents(account);
sam_fill_default_account(account);
return NT_STATUS_OK;
}
/************************************************************
Free the SAM_ACCOUNT_HANDLE and the member pointers.
***********************************************************/
NTSTATUS sam_free_account(SAM_ACCOUNT_HANDLE **account)
{
SMB_ASSERT(*account != NULL);
sam_free_account_contents(*account);
if ((*account)->free_fn) {
(*account)->free_fn(account);
}
return NT_STATUS_OK;
}
/**********************************************************
Encode the account control bits into a string.
length = length of string to encode into (including terminating
null). length *MUST BE MORE THAN 2* !
**********************************************************/
char *sam_encode_acct_ctrl(uint16 acct_ctrl, size_t length)
{
static fstring acct_str;
size_t i = 0;
acct_str[i++] = '[';
if (acct_ctrl & ACB_PWNOTREQ ) acct_str[i++] = 'N';
if (acct_ctrl & ACB_DISABLED ) acct_str[i++] = 'D';
if (acct_ctrl & ACB_HOMDIRREQ) acct_str[i++] = 'H';
if (acct_ctrl & ACB_TEMPDUP ) acct_str[i++] = 'T';
if (acct_ctrl & ACB_NORMAL ) acct_str[i++] = 'U';
if (acct_ctrl & ACB_MNS ) acct_str[i++] = 'M';
if (acct_ctrl & ACB_WSTRUST ) acct_str[i++] = 'W';
if (acct_ctrl & ACB_SVRTRUST ) acct_str[i++] = 'S';
if (acct_ctrl & ACB_AUTOLOCK ) acct_str[i++] = 'L';
if (acct_ctrl & ACB_PWNOEXP ) acct_str[i++] = 'X';
if (acct_ctrl & ACB_DOMTRUST ) acct_str[i++] = 'I';
for ( ; i < length - 2 ; i++ )
acct_str[i] = ' ';
i = length - 2;
acct_str[i++] = ']';
acct_str[i++] = '\0';
return acct_str;
}
/**********************************************************
Decode the account control bits from a string.
**********************************************************/
uint16 sam_decode_acct_ctrl(const char *p)
{
uint16 acct_ctrl = 0;
BOOL finished = False;
/*
* Check if the account type bits have been encoded after the
* NT password (in the form [NDHTUWSLXI]).
*/
if (*p != '[')
return 0;
for (p++; *p && !finished; p++) {
switch (*p) {
case 'N': { acct_ctrl |= ACB_PWNOTREQ ; break; /* 'N'o password. */ }
case 'D': { acct_ctrl |= ACB_DISABLED ; break; /* 'D'isabled. */ }
case 'H': { acct_ctrl |= ACB_HOMDIRREQ; break; /* 'H'omedir required. */ }
case 'T': { acct_ctrl |= ACB_TEMPDUP ; break; /* 'T'emp account. */ }
case 'U': { acct_ctrl |= ACB_NORMAL ; break; /* 'U'ser account (normal). */ }
case 'M': { acct_ctrl |= ACB_MNS ; break; /* 'M'NS logon user account. What is this ? */ }
case 'W': { acct_ctrl |= ACB_WSTRUST ; break; /* 'W'orkstation account. */ }
case 'S': { acct_ctrl |= ACB_SVRTRUST ; break; /* 'S'erver account. */ }
case 'L': { acct_ctrl |= ACB_AUTOLOCK ; break; /* 'L'ocked account. */ }
case 'X': { acct_ctrl |= ACB_PWNOEXP ; break; /* No 'X'piry on password */ }
case 'I': { acct_ctrl |= ACB_DOMTRUST ; break; /* 'I'nterdomain trust account. */ }
case ' ': { break; }
case ':':
case '\n':
case '\0':
case ']':
default: { finished = True; }
}
}
return acct_ctrl;
}
/*************************************************************
Routine to set 32 hex password characters from a 16 byte array.
**************************************************************/
void sam_sethexpwd(char *p, const unsigned char *pwd, uint16 acct_ctrl)
{
if (pwd != NULL) {
int i;
for (i = 0; i < 16; i++)
slprintf(&p[i*2], 3, "%02X", pwd[i]);
} else {
if (acct_ctrl & ACB_PWNOTREQ)
safe_strcpy(p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX", 33);
else
safe_strcpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 33);
}
}
/*************************************************************
Routine to get the 32 hex characters and turn them
into a 16 byte array.
**************************************************************/
BOOL sam_gethexpwd(const char *p, unsigned char *pwd)
{
int i;
unsigned char lonybble, hinybble;
char *hexchars = "0123456789ABCDEF";
char *p1, *p2;
if (!p)
return (False);
for (i = 0; i < 32; i += 2) {
hinybble = toupper(p[i]);
lonybble = toupper(p[i + 1]);
p1 = strchr(hexchars, hinybble);
p2 = strchr(hexchars, lonybble);
if (!p1 || !p2)
return (False);
hinybble = PTR_DIFF(p1, hexchars);
lonybble = PTR_DIFF(p2, hexchars);
pwd[i / 2] = (hinybble << 4) | lonybble;
}
return (True);
}

View File

@ -1,322 +0,0 @@
/*
Unix SMB/CIFS implementation.
SAM interface API.
Copyright (C) Stefan (metze) Metzmacher 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
/* these functions should be used by the rest of SAMBA --metze */
/* General API */
NTSTATUS sam_get_sec_desc(const NT_USER_TOKEN *access_token, const DOM_SID *sid, SEC_DESC **sd)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_sec_desc(sam_context, access_token, sid, sd);
}
NTSTATUS sam_set_sec_desc(const NT_USER_TOKEN *access_token, const DOM_SID *sid, const SEC_DESC *sd)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_set_sec_desc(sam_context, access_token, sid, sd);
}
NTSTATUS sam_lookup_sid(const NT_USER_TOKEN *access_token, const DOM_SID *sid, char **name, uint32 *type)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_lookup_sid(sam_context, access_token, sid, name, type);
}
NTSTATUS sam_lookup_name(const NT_USER_TOKEN *access_token, const char *domain, const char *name, DOM_SID **sid, uint32 *type)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_lookup_name(sam_context, access_token, domain, name, sid, type);
}
/* Domain API */
NTSTATUS sam_update_domain(const SAM_DOMAIN_HANDLE *domain)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_update_domain(sam_context, domain);
}
NTSTATUS sam_enum_domains(const NT_USER_TOKEN *access_token, int32 *domain_count, DOM_SID **domains, char **domain_names)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_enum_domains(sam_context, access_token, domain_count, domains, domain_names);
}
NTSTATUS sam_lookup_domain(const NT_USER_TOKEN * access_token, const char *domain, DOM_SID **domainsid)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_lookup_domain(sam_context, access_token, domain, domainsid);
}
NTSTATUS sam_get_domain_by_sid(const NT_USER_TOKEN *access_token, const uint32 access_desired, const DOM_SID *domainsid, SAM_DOMAIN_HANDLE **domain)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_domain_by_sid(sam_context, access_token, access_desired, domainsid, domain);
}
/* Account API */
NTSTATUS sam_create_account(const NT_USER_TOKEN *access_token, const uint32 access_desired, const DOM_SID *domainsid, const char *account_name, uint16 acct_ctrl, SAM_ACCOUNT_HANDLE **account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_create_account(sam_context, access_token, access_desired, domainsid, account_name, acct_ctrl, account);
}
NTSTATUS sam_add_account(const DOM_SID *domainsid, const SAM_ACCOUNT_HANDLE *account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_add_account(sam_context, domainsid, account);
}
NTSTATUS sam_update_account(const SAM_ACCOUNT_HANDLE *account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_update_account(sam_context, account);
}
NTSTATUS sam_delete_account(const SAM_ACCOUNT_HANDLE *account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_delete_account(sam_context, account);
}
NTSTATUS sam_enum_accounts(const NT_USER_TOKEN *access_token, const DOM_SID *domain, uint16 acct_ctrl, uint32 *account_count, SAM_ACCOUNT_ENUM **accounts)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_enum_accounts(sam_context, access_token, domain, acct_ctrl, account_count, accounts);
}
NTSTATUS sam_get_account_by_sid(const NT_USER_TOKEN *access_token, const uint32 access_desired, const DOM_SID *accountsid, SAM_ACCOUNT_HANDLE **account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_account_by_sid(sam_context, access_token, access_desired, accountsid, account);
}
NTSTATUS sam_get_account_by_name(const NT_USER_TOKEN *access_token, const uint32 access_desired, const char *domain, const char *name, SAM_ACCOUNT_HANDLE **account)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_account_by_name(sam_context, access_token, access_desired, domain, name, account);
}
/* Group API */
NTSTATUS sam_create_group(const NT_USER_TOKEN *access_token, const uint32 access_desired, const DOM_SID *domainsid, const char *group_name, uint16 group_ctrl, SAM_GROUP_HANDLE **group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_create_group(sam_context, access_token, access_desired, domainsid, group_name, group_ctrl, group);
}
NTSTATUS sam_add_group(const DOM_SID *domainsid, const SAM_GROUP_HANDLE *group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_add_group(sam_context, domainsid, group);
}
NTSTATUS sam_update_group(const SAM_GROUP_HANDLE *group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_update_group(sam_context, group);
}
NTSTATUS sam_delete_group(const SAM_GROUP_HANDLE *group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_delete_group(sam_context, group);
}
NTSTATUS sam_enum_groups(const NT_USER_TOKEN *access_token, const DOM_SID *domainsid, uint16 group_ctrl, uint32 *groups_count, SAM_GROUP_ENUM **groups)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_enum_groups(sam_context, access_token, domainsid, group_ctrl, groups_count, groups);
}
NTSTATUS sam_get_group_by_sid(const NT_USER_TOKEN *access_token, const uint32 access_desired, const DOM_SID *groupsid, SAM_GROUP_HANDLE **group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_group_by_sid(sam_context, access_token, access_desired, groupsid, group);
}
NTSTATUS sam_get_group_by_name(const NT_USER_TOKEN *access_token, const uint32 access_desired, const char *domain, const char *name, SAM_GROUP_HANDLE **group)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_group_by_name(sam_context, access_token, access_desired, domain, name, group);
}
NTSTATUS sam_add_member_to_group(const SAM_GROUP_HANDLE *group, const SAM_GROUP_MEMBER *member)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_add_member_to_group(sam_context, group, member);
}
NTSTATUS sam_delete_member_from_group(const SAM_GROUP_HANDLE *group, const SAM_GROUP_MEMBER *member)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_delete_member_from_group(sam_context, group, member);
}
NTSTATUS sam_enum_groupmembers(const SAM_GROUP_HANDLE *group, uint32 *members_count, SAM_GROUP_MEMBER **members)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_enum_groupmembers(sam_context, group, members_count, members);
}
NTSTATUS sam_get_groups_of_sid(const NT_USER_TOKEN *access_token, const DOM_SID **sids, uint16 group_ctrl, uint32 *group_count, SAM_GROUP_ENUM **groups)
{
SAM_CONTEXT *sam_context = sam_get_static_context(False);
if (!sam_context) {
return NT_STATUS_UNSUCCESSFUL;
}
return sam_context->sam_get_groups_of_sid(sam_context, access_token, sids, group_ctrl, group_count, groups);
}

View File

@ -1,872 +0,0 @@
/*
Unix SMB/CIFS implementation.
SAM_ACCOUNT_HANDLE access routines
Copyright (C) Andrew Bartlett 2002
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jelmer Vernooij 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
NTSTATUS sam_get_account_domain_sid(const SAM_ACCOUNT_HANDLE *sampass, const DOM_SID **sid)
{
NTSTATUS status;
SAM_DOMAIN_HANDLE *domain;
SAM_ASSERT(!sampass || !sid);
if (!NT_STATUS_IS_OK(status = sam_get_account_domain(sampass, &domain))){
DEBUG(0, ("sam_get_account_domain_sid: Can't get domain for account\n"));
return status;
}
return sam_get_domain_sid(domain, sid);
}
NTSTATUS sam_get_account_domain_name(const SAM_ACCOUNT_HANDLE *sampass, const char **domain_name)
{
NTSTATUS status;
SAM_DOMAIN_HANDLE *domain;
SAM_ASSERT(sampass && domain_name);
if (!NT_STATUS_IS_OK(status = sam_get_account_domain(sampass, &domain))){
DEBUG(0, ("sam_get_account_domain_name: Can't get domain for account\n"));
return status;
}
return sam_get_domain_name(domain, domain_name);
}
NTSTATUS sam_get_account_acct_ctrl(const SAM_ACCOUNT_HANDLE *sampass, uint16 *acct_ctrl)
{
SAM_ASSERT(sampass && acct_ctrl);
*acct_ctrl = sampass->private.acct_ctrl;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_logon_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *logon_time)
{
SAM_ASSERT(sampass && logon_time) ;
*logon_time = sampass->private.logon_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_logoff_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *logoff_time)
{
SAM_ASSERT(sampass && logoff_time) ;
*logoff_time = sampass->private.logoff_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_kickoff_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *kickoff_time)
{
SAM_ASSERT(sampass && kickoff_time);
*kickoff_time = sampass->private.kickoff_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_pass_last_set_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *pass_last_set_time)
{
SAM_ASSERT(sampass && pass_last_set_time);
*pass_last_set_time = sampass->private.pass_last_set_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_pass_can_change_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *pass_can_change_time)
{
SAM_ASSERT(sampass && pass_can_change_time);
*pass_can_change_time = sampass->private.pass_can_change_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_pass_must_change_time(const SAM_ACCOUNT_HANDLE *sampass, NTTIME *pass_must_change_time)
{
SAM_ASSERT(sampass && pass_must_change_time);
*pass_must_change_time = sampass->private.pass_must_change_time;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_logon_divs(const SAM_ACCOUNT_HANDLE *sampass, uint16 *logon_divs)
{
SAM_ASSERT(sampass && logon_divs);
*logon_divs = sampass->private.logon_divs;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_hours_len(const SAM_ACCOUNT_HANDLE *sampass, uint32 *hours_len)
{
SAM_ASSERT(sampass && hours_len);
*hours_len = sampass->private.hours_len;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_hours(const SAM_ACCOUNT_HANDLE *sampass, const uint8 **hours)
{
SAM_ASSERT(sampass && hours);
*hours = sampass->private.hours;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_nt_pwd(const SAM_ACCOUNT_HANDLE *sampass, DATA_BLOB *nt_pwd)
{
SAM_ASSERT(sampass);
SMB_ASSERT((!sampass->private.nt_pw.data)
|| sampass->private.nt_pw.length == NT_HASH_LEN);
*nt_pwd = sampass->private.nt_pw;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_lm_pwd(const SAM_ACCOUNT_HANDLE *sampass, DATA_BLOB *lm_pwd)
{
SAM_ASSERT(sampass);
SMB_ASSERT((!sampass->private.lm_pw.data)
|| sampass->private.lm_pw.length == LM_HASH_LEN);
*lm_pwd = sampass->private.lm_pw;
return NT_STATUS_OK;
}
/* Return the plaintext password if known. Most of the time
it isn't, so don't assume anything magic about this function.
Used to pass the plaintext to sam backends that might
want to store more than just the NTLM hashes.
*/
NTSTATUS sam_get_account_plaintext_pwd(const SAM_ACCOUNT_HANDLE *sampass, char **plain_pwd)
{
SAM_ASSERT(sampass && plain_pwd);
*plain_pwd = sampass->private.plaintext_pw;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_sid(const SAM_ACCOUNT_HANDLE *sampass, const DOM_SID **sid)
{
SAM_ASSERT(sampass);
*sid = &(sampass->private.account_sid);
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_pgroup(const SAM_ACCOUNT_HANDLE *sampass, const DOM_SID **sid)
{
SAM_ASSERT(sampass);
*sid = &(sampass->private.group_sid);
return NT_STATUS_OK;
}
/**
* Get flags showing what is initalised in the SAM_ACCOUNT_HANDLE
* @param sampass the SAM_ACCOUNT_HANDLE in question
* @return the flags indicating the members initialised in the struct.
**/
NTSTATUS sam_get_account_init_flag(const SAM_ACCOUNT_HANDLE *sampass, uint32 *initflag)
{
SAM_ASSERT(sampass);
*initflag = sampass->private.init_flag;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_name(const SAM_ACCOUNT_HANDLE *sampass, char **account_name)
{
SAM_ASSERT(sampass);
*account_name = sampass->private.account_name;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_domain(const SAM_ACCOUNT_HANDLE *sampass, SAM_DOMAIN_HANDLE **domain)
{
SAM_ASSERT(sampass);
*domain = sampass->private.domain;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_fullname(const SAM_ACCOUNT_HANDLE *sampass, char **fullname)
{
SAM_ASSERT(sampass);
*fullname = sampass->private.full_name;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_homedir(const SAM_ACCOUNT_HANDLE *sampass, char **homedir)
{
SAM_ASSERT(sampass);
*homedir = sampass->private.home_dir;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_unix_home_dir(const SAM_ACCOUNT_HANDLE *sampass, char **uhomedir)
{
SAM_ASSERT(sampass);
*uhomedir = sampass->private.unix_home_dir;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_dir_drive(const SAM_ACCOUNT_HANDLE *sampass, char **dirdrive)
{
SAM_ASSERT(sampass);
*dirdrive = sampass->private.dir_drive;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_logon_script(const SAM_ACCOUNT_HANDLE *sampass, char **logon_script)
{
SAM_ASSERT(sampass);
*logon_script = sampass->private.logon_script;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_profile_path(const SAM_ACCOUNT_HANDLE *sampass, char **profile_path)
{
SAM_ASSERT(sampass);
*profile_path = sampass->private.profile_path;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_description(const SAM_ACCOUNT_HANDLE *sampass, char **description)
{
SAM_ASSERT(sampass);
*description = sampass->private.acct_desc;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_workstations(const SAM_ACCOUNT_HANDLE *sampass, char **workstations)
{
SAM_ASSERT(sampass);
*workstations = sampass->private.workstations;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_unknown_str(const SAM_ACCOUNT_HANDLE *sampass, char **unknown_str)
{
SAM_ASSERT(sampass);
*unknown_str = sampass->private.unknown_str;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_munged_dial(const SAM_ACCOUNT_HANDLE *sampass, char **munged_dial)
{
SAM_ASSERT(sampass);
*munged_dial = sampass->private.munged_dial;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_unknown_1(const SAM_ACCOUNT_HANDLE *sampass, uint32 *unknown1)
{
SAM_ASSERT(sampass && unknown1);
*unknown1 = sampass->private.unknown_1;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_unknown_2(const SAM_ACCOUNT_HANDLE *sampass, uint32 *unknown2)
{
SAM_ASSERT(sampass && unknown2);
*unknown2 = sampass->private.unknown_2;
return NT_STATUS_OK;
}
NTSTATUS sam_get_account_unknown_3(const SAM_ACCOUNT_HANDLE *sampass, uint32 *unknown3)
{
SAM_ASSERT(sampass && unknown3);
*unknown3 = sampass->private.unknown_3;
return NT_STATUS_OK;
}
/*********************************************************************
Collection of set...() functions for SAM_ACCOUNT_HANDLE_INFO.
********************************************************************/
NTSTATUS sam_set_account_acct_ctrl(SAM_ACCOUNT_HANDLE *sampass, uint16 flags)
{
SAM_ASSERT(sampass);
sampass->private.acct_ctrl = flags;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_logon_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime, BOOL store)
{
SAM_ASSERT(sampass);
sampass->private.logon_time = mytime;
if (store)
sam_set_account_init_flag(sampass, FLAG_SAM_LOGONTIME);
return NT_STATUS_UNSUCCESSFUL;
}
NTSTATUS sam_set_account_logoff_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime, BOOL store)
{
SAM_ASSERT(sampass);
sampass->private.logoff_time = mytime;
if (store)
sam_set_account_init_flag(sampass, FLAG_SAM_LOGOFFTIME);
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_kickoff_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime, BOOL store)
{
SAM_ASSERT(sampass);
sampass->private.kickoff_time = mytime;
if (store)
sam_set_account_init_flag(sampass, FLAG_SAM_KICKOFFTIME);
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_pass_can_change_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime, BOOL store)
{
SAM_ASSERT(sampass);
sampass->private.pass_can_change_time = mytime;
if (store)
sam_set_account_init_flag(sampass, FLAG_SAM_CANCHANGETIME);
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_pass_must_change_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime, BOOL store)
{
SAM_ASSERT(sampass);
sampass->private.pass_must_change_time = mytime;
if (store)
sam_set_account_init_flag(sampass, FLAG_SAM_MUSTCHANGETIME);
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_pass_last_set_time(SAM_ACCOUNT_HANDLE *sampass, NTTIME mytime)
{
SAM_ASSERT(sampass);
sampass->private.pass_last_set_time = mytime;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_hours_len(SAM_ACCOUNT_HANDLE *sampass, uint32 len)
{
SAM_ASSERT(sampass);
sampass->private.hours_len = len;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_logon_divs(SAM_ACCOUNT_HANDLE *sampass, uint16 hours)
{
SAM_ASSERT(sampass);
sampass->private.logon_divs = hours;
return NT_STATUS_OK;
}
/**
* Set flags showing what is initalised in the SAM_ACCOUNT_HANDLE
* @param sampass the SAM_ACCOUNT_HANDLE in question
* @param flag The *new* flag to be set. Old flags preserved
* this flag is only added.
**/
NTSTATUS sam_set_account_init_flag(SAM_ACCOUNT_HANDLE *sampass, uint32 flag)
{
SAM_ASSERT(sampass);
sampass->private.init_flag |= flag;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_sid(SAM_ACCOUNT_HANDLE *sampass, const DOM_SID *u_sid)
{
SAM_ASSERT(sampass && u_sid);
sid_copy(&sampass->private.account_sid, u_sid);
DEBUG(10, ("sam_set_account_sid: setting account sid %s\n",
sid_string_static(&sampass->private.account_sid)));
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_sid_from_string(SAM_ACCOUNT_HANDLE *sampass, const char *u_sid)
{
DOM_SID new_sid;
SAM_ASSERT(sampass && u_sid);
DEBUG(10, ("sam_set_account_sid_from_string: setting account sid %s\n",
u_sid));
if (!string_to_sid(&new_sid, u_sid)) {
DEBUG(1, ("sam_set_account_sid_from_string: %s isn't a valid SID!\n", u_sid));
return NT_STATUS_UNSUCCESSFUL;
}
if (!NT_STATUS_IS_OK(sam_set_account_sid(sampass, &new_sid))) {
DEBUG(1, ("sam_set_account_sid_from_string: could not set sid %s on SAM_ACCOUNT_HANDLE!\n", u_sid));
return NT_STATUS_UNSUCCESSFUL;
}
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_pgroup_sid(SAM_ACCOUNT_HANDLE *sampass, const DOM_SID *g_sid)
{
SAM_ASSERT(sampass && g_sid);
sid_copy(&sampass->private.group_sid, g_sid);
DEBUG(10, ("sam_set_group_sid: setting group sid %s\n",
sid_string_static(&sampass->private.group_sid)));
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_pgroup_string(SAM_ACCOUNT_HANDLE *sampass, const char *g_sid)
{
DOM_SID new_sid;
SAM_ASSERT(sampass && g_sid);
DEBUG(10, ("sam_set_group_sid_from_string: setting group sid %s\n",
g_sid));
if (!string_to_sid(&new_sid, g_sid)) {
DEBUG(1, ("sam_set_group_sid_from_string: %s isn't a valid SID!\n", g_sid));
return NT_STATUS_UNSUCCESSFUL;
}
if (!NT_STATUS_IS_OK(sam_set_account_pgroup_sid(sampass, &new_sid))) {
DEBUG(1, ("sam_set_group_sid_from_string: could not set sid %s on SAM_ACCOUNT_HANDLE!\n", g_sid));
return NT_STATUS_UNSUCCESSFUL;
}
return NT_STATUS_OK;
}
/*********************************************************************
Set the domain name.
********************************************************************/
NTSTATUS sam_set_account_domain(SAM_ACCOUNT_HANDLE *sampass, SAM_DOMAIN_HANDLE *domain)
{
SAM_ASSERT(sampass);
sampass->private.domain = domain;
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's NT name.
********************************************************************/
NTSTATUS sam_set_account_name(SAM_ACCOUNT_HANDLE *sampass, const char *account_name)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_account_name: setting nt account_name %s, was %s\n", account_name, sampass->private.account_name));
sampass->private.account_name = talloc_strdup(sampass->mem_ctx, account_name);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's full name.
********************************************************************/
NTSTATUS sam_set_account_fullname(SAM_ACCOUNT_HANDLE *sampass, const char *full_name)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_account_fullname: setting full name %s, was %s\n", full_name, sampass->private.full_name));
sampass->private.full_name = talloc_strdup(sampass->mem_ctx, full_name);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's logon script.
********************************************************************/
NTSTATUS sam_set_account_logon_script(SAM_ACCOUNT_HANDLE *sampass, const char *logon_script, BOOL store)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_logon_script: from %s to %s\n", logon_script, sampass->private.logon_script));
sampass->private.logon_script = talloc_strdup(sampass->mem_ctx, logon_script);
sam_set_account_init_flag(sampass, FLAG_SAM_LOGONSCRIPT);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's profile path.
********************************************************************/
NTSTATUS sam_set_account_profile_path(SAM_ACCOUNT_HANDLE *sampass, const char *profile_path, BOOL store)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_profile_path: setting profile path %s, was %s\n", profile_path, sampass->private.profile_path));
sampass->private.profile_path = talloc_strdup(sampass->mem_ctx, profile_path);
if (store) {
DEBUG(10, ("sam_set_profile_path: setting profile path sam flag!\n"));
sam_set_account_init_flag(sampass, FLAG_SAM_PROFILE);
}
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's directory drive.
********************************************************************/
NTSTATUS sam_set_account_dir_drive(SAM_ACCOUNT_HANDLE *sampass, const char *dir_drive, BOOL store)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_dir_drive: setting dir drive %s, was %s\n", dir_drive,
sampass->private.dir_drive));
sampass->private.dir_drive = talloc_strdup(sampass->mem_ctx, dir_drive);
if (store) {
DEBUG(10, ("sam_set_dir_drive: setting dir drive sam flag!\n"));
sam_set_account_init_flag(sampass, FLAG_SAM_DRIVE);
}
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's home directory.
********************************************************************/
NTSTATUS sam_set_account_homedir(SAM_ACCOUNT_HANDLE *sampass, const char *home_dir, BOOL store)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_homedir: setting home dir %s, was %s\n", home_dir,
sampass->private.home_dir));
sampass->private.home_dir = talloc_strdup(sampass->mem_ctx, home_dir);
if (store) {
DEBUG(10, ("sam_set_homedir: setting home dir sam flag!\n"));
sam_set_account_init_flag(sampass, FLAG_SAM_SMBHOME);
}
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's unix home directory.
********************************************************************/
NTSTATUS sam_set_account_unix_homedir(SAM_ACCOUNT_HANDLE *sampass, const char *unix_home_dir)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_unix_homedir: setting home dir %s, was %s\n", unix_home_dir,
sampass->private.unix_home_dir));
sampass->private.unix_home_dir = talloc_strdup(sampass->mem_ctx, unix_home_dir);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's account description.
********************************************************************/
NTSTATUS sam_set_account_acct_desc(SAM_ACCOUNT_HANDLE *sampass, const char *acct_desc)
{
SAM_ASSERT(sampass);
sampass->private.acct_desc = talloc_strdup(sampass->mem_ctx, acct_desc);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's workstation allowed list.
********************************************************************/
NTSTATUS sam_set_account_workstations(SAM_ACCOUNT_HANDLE *sampass, const char *workstations)
{
SAM_ASSERT(sampass);
DEBUG(10, ("sam_set_workstations: setting workstations %s, was %s\n", workstations,
sampass->private.workstations));
sampass->private.workstations = talloc_strdup(sampass->mem_ctx, workstations);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's 'unknown_str', whatever the heck this actually is...
********************************************************************/
NTSTATUS sam_set_account_unknown_str(SAM_ACCOUNT_HANDLE *sampass, const char *unknown_str)
{
SAM_ASSERT(sampass);
sampass->private.unknown_str = talloc_strdup(sampass->mem_ctx, unknown_str);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's dial string.
********************************************************************/
NTSTATUS sam_set_account_munged_dial(SAM_ACCOUNT_HANDLE *sampass, const char *munged_dial)
{
SAM_ASSERT(sampass);
sampass->private.munged_dial = talloc_strdup(sampass->mem_ctx, munged_dial);
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's NT hash.
********************************************************************/
NTSTATUS sam_set_account_nt_pwd(SAM_ACCOUNT_HANDLE *sampass, const DATA_BLOB data)
{
SAM_ASSERT(sampass);
sampass->private.nt_pw = data;
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's LM hash.
********************************************************************/
NTSTATUS sam_set_account_lm_pwd(SAM_ACCOUNT_HANDLE *sampass, const DATA_BLOB data)
{
SAM_ASSERT(sampass);
sampass->private.lm_pw = data;
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's plaintext password only (base procedure, see helper
below)
********************************************************************/
NTSTATUS sam_set_account_plaintext_pwd(SAM_ACCOUNT_HANDLE *sampass, const char *plain_pwd)
{
SAM_ASSERT(sampass);
sampass->private.plaintext_pw = talloc_strdup(sampass->mem_ctx, plain_pwd);
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_unknown_1(SAM_ACCOUNT_HANDLE *sampass, uint32 unkn)
{
SAM_ASSERT(sampass);
sampass->private.unknown_1 = unkn;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_unknown_2(SAM_ACCOUNT_HANDLE *sampass, uint32 unkn)
{
SAM_ASSERT(sampass);
sampass->private.unknown_2 = unkn;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_unknown_3(SAM_ACCOUNT_HANDLE *sampass, uint32 unkn)
{
SAM_ASSERT(sampass);
sampass->private.unknown_3 = unkn;
return NT_STATUS_OK;
}
NTSTATUS sam_set_account_hours(SAM_ACCOUNT_HANDLE *sampass, const uint8 *hours)
{
SAM_ASSERT(sampass);
if (!hours) {
memset ((char *)sampass->private.hours, 0, MAX_HOURS_LEN);
return NT_STATUS_OK;
}
memcpy(sampass->private.hours, hours, MAX_HOURS_LEN);
return NT_STATUS_OK;
}
/* Helpful interfaces to the above */
/*********************************************************************
Sets the last changed times and must change times for a normal
password change.
********************************************************************/
NTSTATUS sam_set_account_pass_changed_now(SAM_ACCOUNT_HANDLE *sampass)
{
uint32 expire;
NTTIME temptime;
SAM_ASSERT(sampass);
unix_to_nt_time(&temptime, time(NULL));
if (!NT_STATUS_IS_OK(sam_set_account_pass_last_set_time(sampass, temptime)))
return NT_STATUS_UNSUCCESSFUL;
if (!account_policy_get(AP_MAX_PASSWORD_AGE, &expire)
|| (expire==(uint32)-1)) {
get_nttime_max(&temptime);
if (!NT_STATUS_IS_OK(sam_set_account_pass_must_change_time(sampass, temptime, False)))
return NT_STATUS_UNSUCCESSFUL;
} else {
/* FIXME: Add expire to temptime */
if (!NT_STATUS_IS_OK(sam_get_account_pass_last_set_time(sampass,&temptime)) || !NT_STATUS_IS_OK(sam_set_account_pass_must_change_time(sampass, temptime,True)))
return NT_STATUS_UNSUCCESSFUL;
}
return NT_STATUS_OK;
}
/*********************************************************************
Set the account's PLAINTEXT password. Used as an interface to the above.
Also sets the last change time to NOW.
********************************************************************/
NTSTATUS sam_set_account_passwd(SAM_ACCOUNT_HANDLE *sampass, const char *plaintext)
{
DATA_BLOB data;
uchar new_lanman_p16[16];
uchar new_nt_p16[16];
SAM_ASSERT(sampass && plaintext);
nt_lm_owf_gen(plaintext, new_nt_p16, new_lanman_p16);
data = data_blob(new_nt_p16, 16);
if (!NT_STATUS_IS_OK(sam_set_account_nt_pwd(sampass, data)))
return NT_STATUS_UNSUCCESSFUL;
data = data_blob(new_lanman_p16, 16);
if (!NT_STATUS_IS_OK(sam_set_account_lm_pwd(sampass, data)))
return NT_STATUS_UNSUCCESSFUL;
if (!NT_STATUS_IS_OK(sam_set_account_plaintext_pwd(sampass, plaintext)))
return NT_STATUS_UNSUCCESSFUL;
if (!NT_STATUS_IS_OK(sam_set_account_pass_changed_now(sampass)))
return NT_STATUS_UNSUCCESSFUL;
return NT_STATUS_OK;
}

View File

@ -1,263 +0,0 @@
/*
Unix SMB/CIFS implementation.
SAM_DOMAIN access routines
Copyright (C) Andrew Bartlett 2002
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jelmer Vernooij 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
NTSTATUS sam_get_domain_sid(SAM_DOMAIN_HANDLE *domain, const DOM_SID **sid)
{
SAM_ASSERT(domain &&sid);
*sid = &(domain->private.sid);
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_num_accounts(SAM_DOMAIN_HANDLE *domain, uint32 *num_accounts)
{
SAM_ASSERT(domain &&num_accounts);
*num_accounts = domain->private.num_accounts;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_num_groups(SAM_DOMAIN_HANDLE *domain, uint32 *num_groups)
{
SAM_ASSERT(domain &&num_groups);
*num_groups = domain->private.num_groups;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_num_aliases(SAM_DOMAIN_HANDLE *domain, uint32 *num_aliases)
{
SAM_ASSERT(domain &&num_aliases);
*num_aliases = domain->private.num_aliases;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_name(SAM_DOMAIN_HANDLE *domain, const char **domain_name)
{
SAM_ASSERT(domain &&domain_name);
*domain_name = domain->private.name;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_server(SAM_DOMAIN_HANDLE *domain, const char **server_name)
{
SAM_ASSERT(domain &&server_name);
*server_name = domain->private.servername;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_max_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME *max_passwordage)
{
SAM_ASSERT(domain &&max_passwordage);
*max_passwordage = domain->private.max_passwordage;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_min_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME *min_passwordage)
{
SAM_ASSERT(domain &&min_passwordage);
*min_passwordage = domain->private.min_passwordage;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_lockout_duration(SAM_DOMAIN_HANDLE *domain, NTTIME *lockout_duration)
{
SAM_ASSERT(domain &&lockout_duration);
*lockout_duration = domain->private.lockout_duration;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_reset_count(SAM_DOMAIN_HANDLE *domain, NTTIME *reset_lockout_count)
{
SAM_ASSERT(domain &&reset_lockout_count);
*reset_lockout_count = domain->private.reset_count;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_min_pwdlength(SAM_DOMAIN_HANDLE *domain, uint16 *min_passwordlength)
{
SAM_ASSERT(domain &&min_passwordlength);
*min_passwordlength = domain->private.min_passwordlength;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_pwd_history(SAM_DOMAIN_HANDLE *domain, uint16 *password_history)
{
SAM_ASSERT(domain &&password_history);
*password_history = domain->private.password_history;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_lockout_count(SAM_DOMAIN_HANDLE *domain, uint16 *lockout_count)
{
SAM_ASSERT(domain &&lockout_count);
*lockout_count = domain->private.lockout_count;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_force_logoff(SAM_DOMAIN_HANDLE *domain, BOOL *force_logoff)
{
SAM_ASSERT(domain &&force_logoff);
*force_logoff = domain->private.force_logoff;
return NT_STATUS_OK;
}
NTSTATUS sam_get_domain_login_pwdchange(SAM_DOMAIN_HANDLE *domain, BOOL *login_pwdchange)
{
SAM_ASSERT(domain && login_pwdchange);
*login_pwdchange = domain->private.login_pwdchange;
return NT_STATUS_OK;
}
/* Set */
NTSTATUS sam_set_domain_name(SAM_DOMAIN_HANDLE *domain, const char *domain_name)
{
SAM_ASSERT(domain);
domain->private.name = talloc_strdup(domain->mem_ctx, domain_name);
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_max_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME max_passwordage)
{
SAM_ASSERT(domain);
domain->private.max_passwordage = max_passwordage;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_min_pwdage(SAM_DOMAIN_HANDLE *domain, NTTIME min_passwordage)
{
SAM_ASSERT(domain);
domain->private.min_passwordage = min_passwordage;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_lockout_duration(SAM_DOMAIN_HANDLE *domain, NTTIME lockout_duration)
{
SAM_ASSERT(domain);
domain->private.lockout_duration = lockout_duration;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_reset_count(SAM_DOMAIN_HANDLE *domain, NTTIME reset_lockout_count)
{
SAM_ASSERT(domain);
domain->private.reset_count = reset_lockout_count;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_min_pwdlength(SAM_DOMAIN_HANDLE *domain, uint16 min_passwordlength)
{
SAM_ASSERT(domain);
domain->private.min_passwordlength = min_passwordlength;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_pwd_history(SAM_DOMAIN_HANDLE *domain, uint16 password_history)
{
SAM_ASSERT(domain);
domain->private.password_history = password_history;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_lockout_count(SAM_DOMAIN_HANDLE *domain, uint16 lockout_count)
{
SAM_ASSERT(domain);
domain->private.lockout_count = lockout_count;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_force_logoff(SAM_DOMAIN_HANDLE *domain, BOOL force_logoff)
{
SAM_ASSERT(domain);
domain->private.force_logoff = force_logoff;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_login_pwdchange(SAM_DOMAIN_HANDLE *domain, BOOL login_pwdchange)
{
SAM_ASSERT(domain);
domain->private.login_pwdchange = login_pwdchange;
return NT_STATUS_OK;
}
NTSTATUS sam_set_domain_server(SAM_DOMAIN_HANDLE *domain, const char *server_name)
{
SAM_ASSERT(domain);
domain->private.servername = talloc_strdup(domain->mem_ctx, server_name);
return NT_STATUS_OK;
}

View File

@ -1,106 +0,0 @@
/*
Unix SMB/CIFS implementation.
SAM_USER_HANDLE access routines
Copyright (C) Andrew Bartlett 2002
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jelmer Vernooij 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
/* sam group get functions */
NTSTATUS sam_get_group_sid(const SAM_GROUP_HANDLE *group, const DOM_SID **sid)
{
SAM_ASSERT(group && sid);
*sid = &(group->private.sid);
return NT_STATUS_OK;
}
NTSTATUS sam_get_group_ctrl(const SAM_GROUP_HANDLE *group, uint32 *group_ctrl)
{
SAM_ASSERT(group && group_ctrl);
*group_ctrl = group->private.group_ctrl;
return NT_STATUS_OK;
}
NTSTATUS sam_get_group_name(const SAM_GROUP_HANDLE *group, const char **group_name)
{
SAM_ASSERT(group);
*group_name = group->private.group_name;
return NT_STATUS_OK;
}
NTSTATUS sam_get_group_comment(const SAM_GROUP_HANDLE *group, const char **group_desc)
{
SAM_ASSERT(group);
*group_desc = group->private.group_desc;
return NT_STATUS_OK;
}
/* sam group set functions */
NTSTATUS sam_set_group_sid(SAM_GROUP_HANDLE *group, const DOM_SID *sid)
{
SAM_ASSERT(group);
if (!sid)
ZERO_STRUCT(group->private.sid);
else
sid_copy(&(group->private.sid), sid);
return NT_STATUS_OK;
}
NTSTATUS sam_set_group_group_ctrl(SAM_GROUP_HANDLE *group, uint32 group_ctrl)
{
SAM_ASSERT(group);
group->private.group_ctrl = group_ctrl;
return NT_STATUS_OK;
}
NTSTATUS sam_set_group_name(SAM_GROUP_HANDLE *group, const char *group_name)
{
SAM_ASSERT(group);
group->private.group_name = talloc_strdup(group->mem_ctx, group_name);
return NT_STATUS_OK;
}
NTSTATUS sam_set_group_description(SAM_GROUP_HANDLE *group, const char *group_desc)
{
SAM_ASSERT(group);
group->private.group_desc = talloc_strdup(group->mem_ctx, group_desc);
return NT_STATUS_OK;
}

View File

@ -1,193 +0,0 @@
/*
Unix SMB/CIFS implementation.
SAM_GROUP_HANDLE /SAM_GROUP_ENUM helpers
Copyright (C) Stefan (metze) Metzmacher 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
/************************************************************
Fill the SAM_GROUP_HANDLE with default values.
***********************************************************/
static void sam_fill_default_group(SAM_GROUP_HANDLE *group)
{
ZERO_STRUCT(group->private); /* Don't touch the talloc context */
}
static void destroy_sam_group_handle_talloc(SAM_GROUP_HANDLE **group)
{
if (*group) {
talloc_destroy((*group)->mem_ctx);
*group = NULL;
}
}
/**********************************************************************
Alloc memory and initialises a SAM_GROUP_HANDLE on supplied mem_ctx.
***********************************************************************/
NTSTATUS sam_init_group_talloc(TALLOC_CTX *mem_ctx, SAM_GROUP_HANDLE **group)
{
SMB_ASSERT(*group != NULL);
if (!mem_ctx) {
DEBUG(0,("sam_init_group_talloc: mem_ctx was NULL!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
*group=(SAM_GROUP_HANDLE *)talloc(mem_ctx, sizeof(SAM_GROUP_HANDLE));
if (*group==NULL) {
DEBUG(0,("sam_init_group_talloc: error while allocating memory\n"));
return NT_STATUS_NO_MEMORY;
}
(*group)->mem_ctx = mem_ctx;
(*group)->free_fn = NULL;
sam_fill_default_group(*group);
return NT_STATUS_OK;
}
/*************************************************************
Alloc memory and initialises a struct SAM_GROUP_HANDLE.
************************************************************/
NTSTATUS sam_init_group(SAM_GROUP_HANDLE **group)
{
TALLOC_CTX *mem_ctx;
NTSTATUS nt_status;
mem_ctx = talloc_init_named("sam internal SAM_GROUP_HANDLE allocation");
if (!mem_ctx) {
DEBUG(0,("sam_init_group: error while doing talloc_init()\n"));
return NT_STATUS_NO_MEMORY;
}
if (!NT_STATUS_IS_OK(nt_status = sam_init_group_talloc(mem_ctx, group))) {
talloc_destroy(mem_ctx);
return nt_status;
}
(*group)->free_fn = destroy_sam_group_handle_talloc;
return NT_STATUS_OK;
}
/************************************************************
Reset the SAM_GROUP_HANDLE.
***********************************************************/
NTSTATUS sam_reset_group(SAM_GROUP_HANDLE *group)
{
SMB_ASSERT(group != NULL);
sam_fill_default_group(group);
return NT_STATUS_OK;
}
/************************************************************
Free the SAM_GROUP_HANDLE and the member pointers.
***********************************************************/
NTSTATUS sam_free_group(SAM_ACCOUNT_HANDLE **group)
{
SMB_ASSERT(*group != NULL);
if ((*group)->free_fn) {
(*group)->free_fn(group);
}
return NT_STATUS_OK;
}
/**********************************************************
Encode the group control bits into a string.
length = length of string to encode into (including terminating
null). length *MUST BE MORE THAN 2* !
**********************************************************/
char *sam_encode_acct_ctrl(uint16 group_ctrl, size_t length)
{
static fstring group_str;
size_t i = 0;
group_str[i++] = '[';
if (group_ctrl & GCB_LOCAL_GROUP ) group_str[i++] = 'L';
if (group_ctrl & GCB_GLOBAL_GROUP ) group_str[i++] = 'G';
for ( ; i < length - 2 ; i++ )
group_str[i] = ' ';
i = length - 2;
group_str[i++] = ']';
group_str[i++] = '\0';
return group_str;
}
/**********************************************************
Decode the group control bits from a string.
**********************************************************/
uint16 sam_decode_group_ctrl(const char *p)
{
uint16 group_ctrl = 0;
BOOL finished = False;
/*
* Check if the account type bits have been encoded after the
* NT password (in the form [NDHTUWSLXI]).
*/
if (*p != '[')
return 0;
for (p++; *p && !finished; p++) {
switch (*p) {
case 'L': { group_ctrl |= GCB_LOCAL_GROUP; break; /* 'L'ocal Aliases Group. */ }
case 'G': { group_ctrl |= GCB_GLOBAL_GROUP; break; /* 'G'lobal Domain Group. */ }
case ' ': { break; }
case ':':
case '\n':
case '\0':
case ']':
default: { finished = True; }
}
}
return group_ctrl;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +0,0 @@
/*
Unix SMB/CIFS implementation.
Loadable san module interface.
Copyright (C) Jelmer Vernooij 2002
Copyright (C) Andrew Bartlett 2002
Copyright (C) Stefan (metze) Metzmacher 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_SAM
NTSTATUS sam_init_plugin(SAM_METHODS *sam_methods, const char *module_params)
{
void *dl_handle;
char *plugin_params, *plugin_name, *p;
sam_init_function plugin_init;
int (*plugin_version)(void);
if (module_params == NULL) {
DEBUG(0, ("The plugin module needs an argument!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
plugin_name = smb_xstrdup(module_params);
p = strchr(plugin_name, ':');
if (p) {
*p = 0;
plugin_params = p+1;
trim_string(plugin_params, " ", " ");
} else plugin_params = NULL;
trim_string(plugin_name, " ", " ");
DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
dl_handle = sys_dlopen(plugin_name, RTLD_NOW);
if (!dl_handle) {
DEBUG(0, ("Failed to load sam plugin %s using sys_dlopen (%s)\n", plugin_name, sys_dlerror()));
return NT_STATUS_UNSUCCESSFUL;
}
plugin_version = sys_dlsym(dl_handle, "sam_version");
if (!plugin_version) {
sys_dlclose(dl_handle);
DEBUG(0, ("Failed to find function 'sam_version' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
return NT_STATUS_UNSUCCESSFUL;
}
if (plugin_version()!=SAM_INTERFACE_VERSION) {
sys_dlclose(dl_handle);
DEBUG(0, ("Wrong SAM_INTERFACE_VERSION! sam plugin has version %d and version %d is needed! Please update!\n",
plugin_version(),SAM_INTERFACE_VERSION));
return NT_STATUS_UNSUCCESSFUL;
}
plugin_init = sys_dlsym(dl_handle, "sam_init");
if (!plugin_init) {
sys_dlclose(dl_handle);
DEBUG(0, ("Failed to find function 'sam_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
return NT_STATUS_UNSUCCESSFUL;
}
DEBUG(5, ("Starting sam plugin %s with parameters %s for domain %s\n", plugin_name, plugin_params, sam_methods->domain_name));
return plugin_init(sam_methods, plugin_params);
}