added in some pdb_xxx routines that are needed by nispass.c
authorLuke Leighton <lkcl@samba.org>
Tue, 29 Sep 1998 17:56:12 +0000 (17:56 +0000)
committerLuke Leighton <lkcl@samba.org>
Tue, 29 Sep 1998 17:56:12 +0000 (17:56 +0000)
source/include/proto.h
source/include/rpc_lsa.h
source/passdb/passdb.c

index 1c09d627db9494618ea46e3126d5d60e34c42171..eac109345016e75dd4fb61124c968e2c659460c7 100644 (file)
@@ -482,7 +482,7 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val);
 void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
 void E_md4hash(uchar *passwd, uchar *p16);
 void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
-void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
+void SMBOWFencrypt(uchar passwd[16], char *c8, uchar p24[24]);
 void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
 
 /*The following definitions come from  libsmb/smberr.c  */
@@ -1131,6 +1131,14 @@ struct sam_disp_info *pdb_sam_to_dispinfo(struct sam_passwd *user);
 struct smb_passwd *pdb_sam_to_smb(struct sam_passwd *user);
 char *pdb_encode_acct_ctrl(uint16 acct_ctrl, size_t length);
 uint16 pdb_decode_acct_ctrl(char *p);
+time_t pdb_get_last_set_time(char *p);
+void pdb_set_logon_time(char *p, int max_len, time_t t);
+void pdb_set_logoff_time(char *p, int max_len, time_t t);
+void pdb_set_kickoff_time(char *p, int max_len, time_t t);
+void pdb_set_can_change_time(char *p, int max_len, time_t t);
+void pdb_set_must_change_time(char *p, int max_len, time_t t);
+void pdb_set_last_set_time(char *p, int max_len, time_t t);
+void pdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl);
 BOOL pdb_gethexpwd(char *p, char *pwd);
 BOOL pdb_name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid);
 BOOL pdb_generate_machine_sid(void);
index 8bcc4a133865c7e9026c12e6b275d2b2cfb20e9b..ff87ed1bfb9d8b6d5e41682174108e7bce7b2288 100644 (file)
@@ -168,17 +168,18 @@ typedef struct lsa_r_close_info
 /* DOM_R_REF */
 typedef struct dom_ref_info
 {
-    uint32 undoc_buffer; /* undocumented buffer pointer. */
-    uint32 num_ref_doms_1; /* num referenced domains? */
-    uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */
-    uint32 max_entries; /* 32 - max number of entries */
-    uint32 num_ref_doms_2; /* 4 - num referenced domains? */
+       uint32 undoc_buffer; /* undocumented buffer pointer. */
+       uint32 num_ref_doms_1; /* num referenced domains */
+       uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */
+       uint32 max_entries; /* 32 - max number of entries */
+       uint32 num_ref_doms_2; /* num referenced domains */
 
-    UNIHDR2 hdr_dom_name; /* domain name unicode string header */
-    UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
 
-    UNISTR uni_dom_name; /* domain name unicode string */
-    DOM_SID2 ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
+       UNIHDR2 hdr_dom_name; /* domain name unicode string header */
+       UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
+
+       UNISTR uni_dom_name; /* domain name unicode string */
+       DOM_SID2 ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
 
 } DOM_R_REF;
 
@@ -223,7 +224,7 @@ typedef struct lsa_sid_enum_info
 /* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
 typedef struct lsa_q_lookup_sids
 {
-    POLICY_HND          pol_hnd; /* policy handle */
+       POLICY_HND          pol_hnd; /* policy handle */
        LSA_SID_ENUM        sids;
        LSA_TRANS_NAME_ENUM names;
        LOOKUP_LEVEL        level;
@@ -234,7 +235,7 @@ typedef struct lsa_q_lookup_sids
 /* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
 typedef struct lsa_r_lookup_sids
 {
-    DOM_R_REF           *dom_ref; /* domain reference info */
+       DOM_R_REF           *dom_ref; /* domain reference info */
        LSA_TRANS_NAME_ENUM *names;
        uint32              mapped_count;
 
index 15b2e8ed50803152d2dccac4d50a422918bfcc27..55c64f76229f09bb45b86e6d4f3ffe7f00d4d1df 100644 (file)
@@ -570,6 +570,127 @@ uint16 pdb_decode_acct_ctrl(char *p)
        return acct_ctrl;
 }
 
+/*******************************************************************
+ gets password-database-format time from a string.
+ ********************************************************************/
+
+static time_t get_time_from_string(char *p)
+{
+       int i;
+
+       for (i = 0; i < 8; i++)
+       {
+               if (p[i] == '\0' || !isxdigit(p[i]))
+               break;
+       }
+       if (i == 8)
+       {
+               /*
+                * p points at 8 characters of hex digits - 
+                * read into a time_t as the seconds since
+                * 1970 that the password was last changed.
+                */
+               return (time_t)strtol((char *)p, NULL, 16);
+       }
+       return (time_t)-1;
+}
+
+/*******************************************************************
+ gets password last set time
+ ********************************************************************/
+
+time_t pdb_get_last_set_time(char *p)
+{
+       if (*p && StrnCaseCmp((char *)p, "LCT-", 4))
+       {
+               return get_time_from_string(p + 4);
+       }
+       return (time_t)-1;
+}
+
+
+/*******************************************************************
+ sets password-database-format time in a string.
+ ********************************************************************/
+static void set_time_in_string(char *p, int max_len, char *type, time_t t)
+{
+       slprintf(p, max_len, ":%s-%08X:", type, (uint32)t);
+}
+
+/*******************************************************************
+ sets logon time
+ ********************************************************************/
+void pdb_set_logon_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "LNT", t);
+}
+
+/*******************************************************************
+ sets logoff time
+ ********************************************************************/
+void pdb_set_logoff_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "LOT", t);
+}
+
+/*******************************************************************
+ sets kickoff time
+ ********************************************************************/
+void pdb_set_kickoff_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "KOT", t);
+}
+
+/*******************************************************************
+ sets password can change time
+ ********************************************************************/
+void pdb_set_can_change_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "CCT", t);
+}
+
+/*******************************************************************
+ sets password last set time
+ ********************************************************************/
+void pdb_set_must_change_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "MCT", t);
+}
+
+/*******************************************************************
+ sets password last set time
+ ********************************************************************/
+void pdb_set_last_set_time(char *p, int max_len, time_t t)
+{
+       set_time_in_string(p, max_len, "LCT", t);
+}
+
+
+/*************************************************************
+ Routine to set 32 hex password characters from a 16 byte array.
+**************************************************************/
+void pdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl)
+{
+       if (pwd != NULL)
+       {
+               int i;
+               for (i = 0; i < 16; i++)
+               {
+                       slprintf(&p[i*2], 33, "%02X", pwd[i]);
+               }
+       }
+       else
+       {
+               if (IS_BITS_SET_ALL(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.