diff options
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/secrets.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 198f557bd6..fd616c6841 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -245,3 +245,44 @@ void reset_globals_after_fork(void) */ generate_random_buffer( &dummy, 1, True); } + +BOOL secrets_store_ldap_pw(char* dn, char* pw) +{ + fstring key; + char *p; + + pstrcpy(key, dn); + for (p=key; *p; p++) + if (*p == ',') *p = '/'; + + return secrets_store(key, pw, strlen(pw)); +} + +BOOL fetch_ldap_pw(char *dn, char* pw, int len) +{ + fstring key; + char *p; + void *data = NULL; + size_t size; + + pstrcpy(key, dn); + for (p=key; *p; p++) + if (*p == ',') *p = '/'; + + data=secrets_fetch(key, &size); + if (!size) { + DEBUG(0,("fetch_ldap_pw: no ldap secret retrieved!\n")); + return False; + } + + if (size > len-1) + { + DEBUG(0,("fetch_ldap_pw: ldap secret is too long (%d > %d)!\n", size, len-1)); + return False; + } + + memcpy(pw, data, size); + pw[size] = '\0'; + + return True; +} |