⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdb_get_set.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*    Unix SMB/CIFS implementation.   SAM_ACCOUNT access routines   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   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_PASSDB/** * @todo Redefine this to NULL, but this changes the API because *       much of samba assumes that the pdb_get...() funtions  *       return pstrings.  (ie not null-pointers). *       See also pdb_fill_default_sam(). */#define PDB_NOT_QUITE_NULL ""/********************************************************************* Collection of get...() functions for SAM_ACCOUNT. ********************************************************************/uint16 pdb_get_acct_ctrl (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.acct_ctrl);	else		return (ACB_DISABLED);}time_t pdb_get_logon_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.logon_time);	else		return (0);}time_t pdb_get_logoff_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.logoff_time);	else		return (-1);}time_t pdb_get_kickoff_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.kickoff_time);	else		return (-1);}time_t pdb_get_bad_password_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.bad_password_time);	else		return (-1);}time_t pdb_get_pass_last_set_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.pass_last_set_time);	else		return (-1);}time_t pdb_get_pass_can_change_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.pass_can_change_time);	else		return (-1);}time_t pdb_get_pass_must_change_time (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.pass_must_change_time);	else		return (-1);}uint16 pdb_get_logon_divs (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.logon_divs);	else		return (-1);}uint32 pdb_get_hours_len (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.hours_len);	else		return (-1);}const uint8* pdb_get_hours (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.hours);	else		return (NULL);}const uint8* pdb_get_nt_passwd (const SAM_ACCOUNT *sampass){	if (sampass) {		SMB_ASSERT((!sampass->private_u.nt_pw.data) 			   || sampass->private_u.nt_pw.length == NT_HASH_LEN);		return ((uint8*)sampass->private_u.nt_pw.data);	}	else		return (NULL);}const uint8* pdb_get_lanman_passwd (const SAM_ACCOUNT *sampass){	if (sampass) {		SMB_ASSERT((!sampass->private_u.lm_pw.data) 			   || sampass->private_u.lm_pw.length == LM_HASH_LEN);		return ((uint8*)sampass->private_u.lm_pw.data);	}	else		return (NULL);}const uint8* pdb_get_pw_history (const SAM_ACCOUNT *sampass, uint32 *current_hist_len){	if (sampass) {		SMB_ASSERT((!sampass->private_u.nt_pw_his.data) 		   || ((sampass->private_u.nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));		*current_hist_len = sampass->private_u.nt_pw_his.length / PW_HISTORY_ENTRY_LEN;		return ((uint8*)sampass->private_u.nt_pw_his.data);	} else {		*current_hist_len = 0;		return (NULL);	}}/* 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 passdb backends that might    want to store more than just the NTLM hashes.*/const char* pdb_get_plaintext_passwd (const SAM_ACCOUNT *sampass){	if (sampass) {		return (sampass->private_u.plaintext_pw);	}	else		return (NULL);}const DOM_SID *pdb_get_user_sid(const SAM_ACCOUNT *sampass){	if (sampass) 		return &sampass->private_u.user_sid;	else		return (NULL);}const DOM_SID *pdb_get_group_sid(const SAM_ACCOUNT *sampass){	if (sampass)		return &sampass->private_u.group_sid;	else			return (NULL);}	/** * Get flags showing what is initalised in the SAM_ACCOUNT * @param sampass the SAM_ACCOUNT in question * @return the flags indicating the members initialised in the struct. **/ enum pdb_value_state pdb_get_init_flags (const SAM_ACCOUNT *sampass, enum pdb_elements element){	enum pdb_value_state ret = PDB_DEFAULT;	        if (!sampass || !sampass->private_u.change_flags || !sampass->private_u.set_flags)        	return ret;        	        if (bitmap_query(sampass->private_u.set_flags, element)) {		DEBUG(11, ("element %d: SET\n", element));         	ret = PDB_SET;	}		        if (bitmap_query(sampass->private_u.change_flags, element)) {		DEBUG(11, ("element %d: CHANGED\n", element));         	ret = PDB_CHANGED;	}	if (ret == PDB_DEFAULT) {		DEBUG(11, ("element %d: DEFAULT\n", element)); 	}        return ret;}const char* pdb_get_username (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.username);	else		return (NULL);}const char* pdb_get_domain (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.domain);	else		return (NULL);}const char* pdb_get_nt_username (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.nt_username);	else		return (NULL);}const char* pdb_get_fullname (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.full_name);	else		return (NULL);}const char* pdb_get_homedir (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.home_dir);	else		return (NULL);}const char* pdb_get_unix_homedir (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.unix_home_dir);	else		return (NULL);}const char* pdb_get_dir_drive (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.dir_drive);	else		return (NULL);}const char* pdb_get_logon_script (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.logon_script);	else		return (NULL);}const char* pdb_get_profile_path (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.profile_path);	else		return (NULL);}const char* pdb_get_acct_desc (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.acct_desc);	else		return (NULL);}const char* pdb_get_workstations (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.workstations);	else		return (NULL);}const char* pdb_get_unknown_str (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.unknown_str);	else		return (NULL);}const char* pdb_get_munged_dial (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.munged_dial);	else		return (NULL);}uint16 pdb_get_bad_password_count(const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.bad_password_count);	else		return 0;}uint16 pdb_get_logon_count(const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.logon_count);	else		return 0;}uint32 pdb_get_unknown_6 (const SAM_ACCOUNT *sampass){	if (sampass)		return (sampass->private_u.unknown_6);	else		return (-1);}void *pdb_get_backend_private_data (const SAM_ACCOUNT *sampass, const struct pdb_methods *my_methods){	if (sampass && my_methods == sampass->private_u.backend_private_methods)		return sampass->private_u.backend_private_data;	else		return NULL;}/********************************************************************* Collection of set...() functions for SAM_ACCOUNT. ********************************************************************/BOOL pdb_set_acct_ctrl (SAM_ACCOUNT *sampass, uint16 acct_ctrl, enum pdb_value_state flag){	if (!sampass)		return False;			sampass->private_u.acct_ctrl = acct_ctrl;	return pdb_set_init_flags(sampass, PDB_ACCTCTRL, flag);}BOOL pdb_set_logon_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag){	if (!sampass)		return False;	sampass->private_u.logon_time = mytime;	return pdb_set_init_flags(sampass, PDB_LOGONTIME, flag);}BOOL pdb_set_logoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag){	if (!sampass)		return False;	sampass->private_u.logoff_time = mytime;	return pdb_set_init_flags(sampass, PDB_LOGOFFTIME, flag);}BOOL pdb_set_kickoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag){	if (!sampass)		return False;	sampass->private_u.kickoff_time = mytime;	return pdb_set_init_flags(sampass, PDB_KICKOFFTIME, flag);}BOOL pdb_set_bad_password_time (SAM_ACCOUNT *sampass, time_t mytime, 				enum pdb_value_state flag){	if (!sampass)		return False;	sampass->private_u.bad_password_time = mytime;	return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_TIME, flag);}BOOL pdb_set_pass_can_change_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag){	if (!sampass)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -