summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/smbldap.h1
-rw-r--r--source3/lib/smbldap.c1
-rw-r--r--source3/passdb/passdb.c51
-rw-r--r--source3/passdb/pdb_ldap.c23
4 files changed, 74 insertions, 2 deletions
diff --git a/source3/include/smbldap.h b/source3/include/smbldap.h
index 6046af464e..953937fb75 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 0980b763ad..e66fb3640c 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 e404f5af3f..0905d81692 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 37cc0c7902..9af34705df 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,