summaryrefslogtreecommitdiffstats
path: root/source/passdb/passdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-08-13 18:02:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:21 -0500
commitdac72638fb3a05e805136698e0ad0612620ac8af (patch)
tree0ebb7469e13ef238c7a0638cdbeb4837a50d974e /source/passdb/passdb.c
parentac0fdf9503b34a70eaae5e7cf0764dbaec0263ee (diff)
downloadsamba-dac72638fb3a05e805136698e0ad0612620ac8af.tar.gz
samba-dac72638fb3a05e805136698e0ad0612620ac8af.tar.xz
samba-dac72638fb3a05e805136698e0ad0612620ac8af.zip
r1810: Patch from Richard Renard <rrenard@idealx.com> to store
logon hours attributes in an LDAP database. Jeremy.
Diffstat (limited to 'source/passdb/passdb.c')
-rw-r--r--source/passdb/passdb.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/passdb/passdb.c b/source/passdb/passdb.c
index e404f5af3f9..0905d816920 100644
--- a/source/passdb/passdb.c
+++ b/source/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;