password API needed

Luke Kenneth Casson Leighton lkcl at cb1.com
Mon May 11 16:17:28 GMT 1998


ok, this is the new password database API.

expected usage:
--------------

- struct sam_passwd enumeration will be called from, for example,
lib/rpc/server/srv_samr.c's SamrEnumDomUsers function, and also from
ipc.c's NetUserGetInfo and WkstaUserLogon SMBtrans2 functions.

- struct smb_passwd enumeration will be called in almost every other place



proposed modifications:
----------------------

- if a member smb_fullname could be added to struct smb_passwd, then the
SamrQueryDispInfo function need not call the sam_passwd function but the
smb_passwd function instead.  this will dramatically cut down the update
time once USRMGR.EXE support is working properly. 

in smbpass.c, this could be done by reading the standard unix struct
passwd "pw_gecos" /* real name */ member.

in ldap.c, this could be done by reading the "userFullName" database
entry.



still to go:
-----------

- support for getsam21pwnam/uid in smbpass.c.
- tying in the ldap routines properly
- writing mod_ldappwd_entry and add_ldappwd_entry routines (jean-f?)


#define MAX_HOURS_LEN 32

struct sam_passwd
{
	time_t logon_time;            /* logon time */
	time_t logoff_time;           /* logoff time */
	time_t kickoff_time;          /* kickoff time */
	time_t pass_last_set_time;    /* password last set time */
	time_t pass_can_change_time;  /* password can change time */
	time_t pass_must_change_time; /* password must change time */

	char *smb_name;     /* username string */
	char *full_name;    /* user's full name string */
	char *home_dir;     /* home directory string */
	char *dir_drive;    /* home directory drive string */
	char *logon_script; /* logon script string */
	char *profile_path; /* profile path string */
	char *acct_desc  ;  /* user description string */
	char *workstations; /* login from workstations string */
	char *unknown_str ; /* don't know what this is, yet. */
	char *munged_dial ; /* munged path name and dial-back tel number */

	int smb_userid;       /* this is actually the unix uid_t */
	int smb_grpid;        /* this is actually the unix gid_t */
	uint32 user_rid;      /* Primary User ID */
	uint32 group_rid;     /* Primary Group ID */

	unsigned char *smb_passwd; /* Null if no password */
	unsigned char *smb_nt_passwd; /* Null if no password */

	uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
	uint32 unknown_3; /* 0x00ff ffff */

	uint16 logon_divs; /* 168 - number of hours in a week */
	uint32 hours_len; /* normally 21 bytes */
	uint8 hours[MAX_HOURS_LEN];

	uint32 unknown_5; /* 0x0002 0000 */
	uint32 unknown_6; /* 0x0000 04ec */
};

struct smb_passwd
{
	int smb_userid;     /* this is actually the unix uid_t */
	char *smb_name;     /* username string */

	unsigned char *smb_passwd; /* Null if no password */
	unsigned char *smb_nt_passwd; /* Null if no password */

	uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
	time_t pass_last_set_time;    /* password last set time */
};


/*The following definitions come from  passdb.c  */

/* low-level enumeration routines */

void              *startsampwent(BOOL update);
void               endsampwent(void *vp);
struct smb_passwd *getsampwent(void *vp);
struct sam_passwd *getsam21pwent(void *vp);

unsigned long getsampwpos(void *vp);
BOOL          setsampwpos(void *vp, unsigned long tok);

/* slightly higher-level routines */

BOOL add_sampwd_entry(struct smb_passwd *newpwd);
BOOL add_sam21pwd_entry(struct sam_passwd *newpwd);
BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override);
BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override);

struct smb_passwd *getsampwnam(char *name);
struct sam_passwd *getsam21pwnam(char *name);
struct smb_passwd *getsampwuid(uid_t smb_userid);
struct sam_passwd *getsam21pwrid(uint32 rid);

/* useful utils */

char *encode_acct_ctrl(uint16 acct_ctrl);
uint16 decode_acct_ctrl(char *p);
int gethexpwd(char *p, char *pwd);

BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid);
uid_t user_rid_to_uid(uint32 u_rid);
uid_t group_rid_to_uid(uint32 u_gid);
uint32 uid_to_user_rid(uint32 uid);
uint32 gid_to_group_rid(uint32 gid);



More information about the samba-technical mailing list