diff options
author | Jeremy Allison <jra@samba.org> | 2004-08-13 18:02:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:21 -0500 |
commit | bdab948fcfee56871e7a21825c09a116b4274f37 (patch) | |
tree | 4564b8874806976e615210f456a2258c9090d952 /source3 | |
parent | 7af12653687768ea08ca225914e6558ab74c95f0 (diff) | |
download | samba-bdab948fcfee56871e7a21825c09a116b4274f37.tar.gz samba-bdab948fcfee56871e7a21825c09a116b4274f37.tar.xz samba-bdab948fcfee56871e7a21825c09a116b4274f37.zip |
r1810: Patch from Richard Renard <rrenard@idealx.com> to store
logon hours attributes in an LDAP database.
Jeremy.
(This used to be commit dac72638fb3a05e805136698e0ad0612620ac8af)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/smbldap.h | 1 | ||||
-rw-r--r-- | source3/lib/smbldap.c | 1 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 51 | ||||
-rw-r--r-- | source3/passdb/pdb_ldap.c | 23 |
4 files changed, 74 insertions, 2 deletions
diff --git a/source3/include/smbldap.h b/source3/include/smbldap.h index 6046af464e6..953937fb75d 100644 --- a/source3/include/smbldap.h +++ b/source3/include/smbldap.h @@ -96,6 +96,7 @@ #define LDAP_ATTR_PWD_HISTORY 39 #define LDAP_ATTR_SID_LIST 40 #define LDAP_ATTR_MOD_TIMESTAMP 41 +#define LDAP_ATTR_LOGON_HOURS 42 typedef struct _attrib_map_entry { int attrib; diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 0980b763adb..e66fb3640cf 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -102,6 +102,7 @@ ATTRIB_MAP_ENTRY attrib_map_v30[] = { { LDAP_ATTR_BAD_PASSWORD_TIME, "sambaBadPasswordTime" }, { LDAP_ATTR_PWD_HISTORY, "sambaPasswordHistory" }, { LDAP_ATTR_MOD_TIMESTAMP, "modifyTimestamp" }, + { LDAP_ATTR_LOGON_HOURS, "sambaLogonHours" }, { LDAP_ATTR_LIST_END, NULL } }; diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index e404f5af3f9..0905d816920 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -583,6 +583,57 @@ BOOL pdb_gethexpwd(const char *p, unsigned char *pwd) return (True); } +/************************************************************* + Routine to set 42 hex hours characters from a 21 byte array. +**************************************************************/ + +void pdb_sethexhours(char *p, const unsigned char *hours) +{ + if (hours != NULL) { + int i; + for (i = 0; i < 21; i++) { + slprintf(&p[i*2], 3, "%02X", hours[i]); + } + } else { + safe_strcpy(p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 43); + } +} + +/************************************************************* + Routine to get the 42 hex characters and turn them + into a 21 byte array. +**************************************************************/ + +BOOL pdb_gethexhours(const char *p, unsigned char *hours) +{ + int i; + unsigned char lonybble, hinybble; + const char *hexchars = "0123456789ABCDEF"; + char *p1, *p2; + + if (!p) { + return (False); + } + + for (i = 0; i < 42; 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); + + hours[i / 2] = (hinybble << 4) | lonybble; + } + return (True); +} + int algorithmic_rid_base(void) { static int rid_offset = 0; diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 37cc0c79029..9af34705df5 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -782,7 +782,15 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state, /* pdb_set_unknown_6(sampass, unknown6, PDB_SET); */ - pdb_set_hours(sampass, hours, PDB_SET); + if(!smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry, + get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGON_HOURS), temp)) { + /* leave as default */ + } else { + pdb_gethexhours(temp, hours); + memset((char *)temp, '\0', strlen(temp) +1); + pdb_set_hours(sampass, hours, PDB_SET); + ZERO_STRUCT(hours); + } /* check the timestamp of the cache vs ldap entry */ if (!(ldap_entry_time = ldapsam_get_entry_timestamp(ldap_state, @@ -1065,7 +1073,18 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, } } - /* FIXME: Hours stuff goes in LDAP */ + if (need_update(sampass, PDB_HOURS)) { + const char *hours = pdb_get_hours(sampass); + if (hours) { + pdb_sethexhours(temp, hours); + smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, + existing, + mods, + get_userattr_key2string(ldap_state->schema_ver, + LDAP_ATTR_LOGON_HOURS), + temp); + } + } if (need_update(sampass, PDB_ACCTCTRL)) smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, existing, mods, |