1 /* smbk5pwd.c - Overlay for managing Samba and Heimdal passwords */
4 * Copyright 2004-2005 by Howard Chu, Symas Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * Support for sambaPwdMustChange added by Marco D'Ettorre.
17 * Support for table-driven configuration added by Pierangelo Masarati.
19 * The conditions of the OpenLDAP Public License apply.
24 #ifndef SLAPD_OVER_SMBK5PWD
25 #define SLAPD_OVER_SMBK5PWD SLAPD_MOD_DYNAMIC
28 #ifdef SLAPD_OVER_SMBK5PWD
32 #include <ac/string.h>
41 /* make ASN1_MALLOC_ENCODE use our allocator */
42 #define malloc ch_malloc
45 #include <kadm5/admin.h>
48 #ifndef HDB_INTERFACE_VERSION
49 #define HDB_MASTER_KEY_SET master_key_set
51 #define HDB_MASTER_KEY_SET hdb_master_key_set
54 static krb5_context context;
55 static void *kadm_context;
56 static kadm5_config_params conf;
59 static AttributeDescription *ad_krb5Key;
60 static AttributeDescription *ad_krb5KeyVersionNumber;
61 static AttributeDescription *ad_krb5PrincipalName;
62 static ObjectClass *oc_krb5KDCEntry;
66 #include <openssl/des.h>
67 #include <openssl/md4.h>
68 #include "ldap_utf8.h"
70 static AttributeDescription *ad_sambaLMPassword;
71 static AttributeDescription *ad_sambaNTPassword;
72 static AttributeDescription *ad_sambaPwdLastSet;
73 static AttributeDescription *ad_sambaPwdMustChange;
74 static ObjectClass *oc_sambaSamAccount;
77 /* Per-instance configuration information */
78 typedef struct smbk5pwd_t {
80 #define SMBK5PWD_F_KRB5 (0x1U)
81 #define SMBK5PWD_F_SAMBA (0x2U)
83 #define SMBK5PWD_DO_KRB5(pi) ((pi)->mode & SMBK5PWD_F_KRB5)
84 #define SMBK5PWD_DO_SAMBA(pi) ((pi)->mode & SMBK5PWD_F_SAMBA)
91 /* How many seconds before forcing a password change? */
92 time_t smb_must_change;
96 static const unsigned SMBK5PWD_F_ALL =
106 static int smbk5pwd_modules_init( smbk5pwd_t *pi );
109 static const char hex[] = "0123456789abcdef";
111 /* From liblutil/passwd.c... */
112 static void lmPasswd_to_key(
113 const char *lmPasswd,
116 const unsigned char *lpw = (const unsigned char *)lmPasswd;
117 unsigned char *k = (unsigned char *)key;
119 /* make room for parity bits */
121 k[1] = ((lpw[0]&0x01)<<7) | (lpw[1]>>1);
122 k[2] = ((lpw[1]&0x03)<<6) | (lpw[2]>>2);
123 k[3] = ((lpw[2]&0x07)<<5) | (lpw[3]>>3);
124 k[4] = ((lpw[3]&0x0F)<<4) | (lpw[4]>>4);
125 k[5] = ((lpw[4]&0x1F)<<3) | (lpw[5]>>5);
126 k[6] = ((lpw[5]&0x3F)<<2) | (lpw[6]>>6);
127 k[7] = ((lpw[6]&0x7F)<<1);
129 des_set_odd_parity( key );
132 #define MAX_PWLEN 256
136 const char in[HASHLEN],
144 out->bv_val = ch_malloc(HASHLEN*2 + 1);
145 out->bv_len = HASHLEN*2;
148 b = (unsigned char *)in;
149 for (i=0; i<HASHLEN; i++) {
151 *a++ = hex[*b++ & 0x0f];
157 struct berval *passwd,
161 char UcasePassword[15];
163 des_key_schedule schedule;
164 des_cblock StdText = "KGS!@#$%";
167 strncpy( UcasePassword, passwd->bv_val, 14 );
168 UcasePassword[14] = '\0';
169 ldap_pvt_str2upper( UcasePassword );
171 lmPasswd_to_key( UcasePassword, &key );
172 des_set_key_unchecked( &key, schedule );
173 des_ecb_encrypt( &StdText, &hbuf[0], schedule , DES_ENCRYPT );
175 lmPasswd_to_key( &UcasePassword[7], &key );
176 des_set_key_unchecked( &key, schedule );
177 des_ecb_encrypt( &StdText, &hbuf[1], schedule , DES_ENCRYPT );
179 hexify( (char *)hbuf, hash );
183 struct berval *passwd,
187 /* Windows currently only allows 14 character passwords, but
188 * may support up to 256 in the future. We assume this means
189 * 256 UCS2 characters, not 256 bytes...
194 if (passwd->bv_len > MAX_PWLEN*2)
195 passwd->bv_len = MAX_PWLEN*2;
198 MD4_Update( &ctx, passwd->bv_val, passwd->bv_len );
199 MD4_Final( (unsigned char *)hbuf, &ctx );
201 hexify( hbuf, hash );
203 #endif /* DO_SAMBA */
207 static int smbk5pwd_op_cleanup(
213 /* clear out the current key */
214 ldap_pvt_thread_pool_setkey( op->o_threadctx, smbk5pwd_op_cleanup,
217 /* free the callback */
219 op->o_callback = cb->sc_next;
220 op->o_tmpfree( cb, op->o_tmpmemctx );
224 static int smbk5pwd_op_bind(
228 /* If this is a simple Bind, stash the Op pointer so our chk
229 * function can find it. Set a cleanup callback to clear it
230 * out when the Bind completes.
232 if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE ) {
234 ldap_pvt_thread_pool_setkey( op->o_threadctx, smbk5pwd_op_cleanup, op,
236 cb = op->o_tmpcalloc( 1, sizeof(slap_callback), op->o_tmpmemctx );
237 cb->sc_cleanup = smbk5pwd_op_cleanup;
238 cb->sc_next = op->o_callback;
241 return SLAP_CB_CONTINUE;
244 static LUTIL_PASSWD_CHK_FUNC k5key_chk;
245 static LUTIL_PASSWD_HASH_FUNC k5key_hash;
246 static const struct berval k5key_scheme = BER_BVC("{K5KEY}");
248 /* This password scheme stores no data in the userPassword attribute
249 * other than the scheme name. It assumes the invoking entry is a
250 * krb5KDCentry and compares the passed-in credentials against the
251 * krb5Key attribute. The krb5Key may be multi-valued, but they are
252 * simply multiple keytypes generated from the same input string, so
253 * only the first value needs to be compared here.
255 * Since the lutil_passwd API doesn't pass the Entry object in, we
256 * have to fetch it ourselves in order to get access to the other
257 * attributes. We accomplish this with the help of the overlay's Bind
258 * function, which stores the current Operation pointer in thread-specific
259 * storage so we can retrieve it here. The Operation provides all
260 * the necessary context for us to get Entry from the database.
262 static int k5key_chk(
263 const struct berval *sc,
264 const struct berval *passwd,
265 const struct berval *cred,
278 /* Find our thread context, find our Operation */
279 ctx = ldap_pvt_thread_pool_context();
281 if ( ldap_pvt_thread_pool_getkey( ctx, smbk5pwd_op_cleanup, (void **)&op, NULL ) ||
283 return LUTIL_PASSWD_ERR;
285 rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
286 if ( rc != LDAP_SUCCESS ) return LUTIL_PASSWD_ERR;
288 rc = LUTIL_PASSWD_ERR;
293 a = attr_find( e->e_attrs, ad_krb5PrincipalName );
296 memset( &ent, 0, sizeof(ent) );
297 ret = krb5_parse_name(context, a->a_vals[0].bv_val, &ent.principal);
299 krb5_get_pw_salt( context, ent.principal, &salt );
300 krb5_free_principal( context, ent.principal );
302 a = attr_find( e->e_attrs, ad_krb5Key );
306 ent.keys.val = &ekey;
307 decode_Key((unsigned char *) a->a_vals[0].bv_val,
308 (size_t) a->a_vals[0].bv_len, &ent.keys.val[0], &l);
309 if ( db->HDB_MASTER_KEY_SET )
310 hdb_unseal_keys( context, db, &ent );
312 krb5_string_to_key_salt( context, ekey.key.keytype, cred->bv_val,
315 krb5_free_salt( context, salt );
317 if ( memcmp( ekey.key.keyvalue.data, key.keyvalue.data,
318 key.keyvalue.length ) == 0 ) rc = LUTIL_PASSWD_OK;
320 krb5_free_keyblock_contents( context, &key );
321 krb5_free_keyblock_contents( context, &ekey.key );
324 be_entry_release_r( op, e );
328 static int k5key_hash(
329 const struct berval *scheme,
330 const struct berval *passwd,
334 ber_dupbv( hash, (struct berval *)&k5key_scheme );
335 return LUTIL_PASSWD_OK;
339 static int smbk5pwd_exop_passwd(
344 req_pwdexop_s *qpw = &op->oq_pwdexop;
347 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
348 smbk5pwd_t *pi = on->on_bi.bi_private;
350 /* Not the operation we expected, pass it on... */
351 if ( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) ) {
352 return SLAP_CB_CONTINUE;
355 op->o_bd->bd_info = (BackendInfo *)on->on_info;
356 rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
357 if ( rc != LDAP_SUCCESS ) return rc;
368 if ( !SMBK5PWD_DO_KRB5( pi ) ) break;
370 if ( !is_entry_objectclass(e, oc_krb5KDCEntry, 0 ) ) break;
372 a = attr_find( e->e_attrs, ad_krb5PrincipalName );
375 memset( &ent, 0, sizeof(ent) );
376 ret = krb5_parse_name(context, a->a_vals[0].bv_val, &ent.principal);
379 a = attr_find( e->e_attrs, ad_krb5KeyVersionNumber );
381 kvno = atoi(a->a_vals[0].bv_val);
383 /* shouldn't happen, this is a required attr */
387 ret = _kadm5_set_keys(kadm_context, &ent, qpw->rs_new.bv_val);
388 hdb_seal_keys(context, db, &ent);
389 krb5_free_principal( context, ent.principal );
391 keys = ch_malloc( (ent.keys.len + 1) * sizeof(struct berval));
393 for (i = 0; i < ent.keys.len; i++) {
397 ASN1_MALLOC_ENCODE(Key, buf, len, &ent.keys.val[i], &len, ret);
401 keys[i].bv_val = (char *)buf;
402 keys[i].bv_len = len;
404 BER_BVZERO( &keys[i] );
406 _kadm5_free_keys(kadm_context, ent.keys.len, ent.keys.val);
408 if ( i != ent.keys.len ) {
409 ber_bvarray_free( keys );
413 ml = ch_malloc(sizeof(Modifications));
414 if (!qpw->rs_modtail) qpw->rs_modtail = &ml->sml_next;
415 ml->sml_next = qpw->rs_mods;
418 ml->sml_desc = ad_krb5Key;
419 ml->sml_op = LDAP_MOD_REPLACE;
420 #ifdef SLAP_MOD_INTERNAL
421 ml->sml_flags = SLAP_MOD_INTERNAL;
423 ml->sml_values = keys;
424 ml->sml_nvalues = NULL;
426 ml = ch_malloc(sizeof(Modifications));
427 ml->sml_next = qpw->rs_mods;
430 ml->sml_desc = ad_krb5KeyVersionNumber;
431 ml->sml_op = LDAP_MOD_REPLACE;
432 #ifdef SLAP_MOD_INTERNAL
433 ml->sml_flags = SLAP_MOD_INTERNAL;
435 ml->sml_values = ch_malloc( 2 * sizeof(struct berval));
436 ml->sml_values[0].bv_val = ch_malloc( 64 );
437 ml->sml_values[0].bv_len = sprintf(ml->sml_values[0].bv_val,
439 BER_BVZERO( &ml->sml_values[1] );
440 ml->sml_nvalues = NULL;
446 if ( SMBK5PWD_DO_SAMBA( pi ) && is_entry_objectclass(e, oc_sambaSamAccount, 0 ) ) {
453 /* Expand incoming UTF8 string to UCS4 */
454 l = ldap_utf8_chars(qpw->rs_new.bv_val);
455 wcs = ch_malloc((l+1) * sizeof(wchar_t));
457 ldap_x_utf8s_to_wcs( wcs, qpw->rs_new.bv_val, l );
459 /* Truncate UCS4 to UCS2 */
461 for (j=0; j<l; j++) {
464 *c++ = (wc >> 8) & 0xff;
467 pwd.bv_val = (char *)wcs;
470 ml = ch_malloc(sizeof(Modifications));
471 if (!qpw->rs_modtail) qpw->rs_modtail = &ml->sml_next;
472 ml->sml_next = qpw->rs_mods;
475 keys = ch_malloc( 2 * sizeof(struct berval) );
476 BER_BVZERO( &keys[1] );
477 nthash( &pwd, keys );
479 ml->sml_desc = ad_sambaNTPassword;
480 ml->sml_op = LDAP_MOD_REPLACE;
481 #ifdef SLAP_MOD_INTERNAL
482 ml->sml_flags = SLAP_MOD_INTERNAL;
484 ml->sml_values = keys;
485 ml->sml_nvalues = NULL;
487 /* Truncate UCS2 to 8-bit ASCII */
490 for (j=1; j<l; j++) {
495 pwd.bv_val[pwd.bv_len] = '\0';
497 ml = ch_malloc(sizeof(Modifications));
498 ml->sml_next = qpw->rs_mods;
501 keys = ch_malloc( 2 * sizeof(struct berval) );
502 BER_BVZERO( &keys[1] );
503 lmhash( &pwd, keys );
505 ml->sml_desc = ad_sambaLMPassword;
506 ml->sml_op = LDAP_MOD_REPLACE;
507 #ifdef SLAP_MOD_INTERNAL
508 ml->sml_flags = SLAP_MOD_INTERNAL;
510 ml->sml_values = keys;
511 ml->sml_nvalues = NULL;
515 ml = ch_malloc(sizeof(Modifications));
516 ml->sml_next = qpw->rs_mods;
519 keys = ch_malloc( 2 * sizeof(struct berval) );
520 keys[0].bv_val = ch_malloc( STRLENOF( "9223372036854775807L" ) + 1 );
521 keys[0].bv_len = snprintf(keys[0].bv_val,
522 STRLENOF( "9223372036854775807L" ) + 1,
523 "%ld", slap_get_time());
524 BER_BVZERO( &keys[1] );
526 ml->sml_desc = ad_sambaPwdLastSet;
527 ml->sml_op = LDAP_MOD_REPLACE;
528 #ifdef SLAP_MOD_INTERNAL
529 ml->sml_flags = SLAP_MOD_INTERNAL;
531 ml->sml_values = keys;
532 ml->sml_nvalues = NULL;
534 if (pi->smb_must_change)
536 ml = ch_malloc(sizeof(Modifications));
537 ml->sml_next = qpw->rs_mods;
540 keys = ch_malloc( 2 * sizeof(struct berval) );
541 keys[0].bv_val = ch_malloc( STRLENOF( "9223372036854775807L" ) + 1 );
542 keys[0].bv_len = snprintf(keys[0].bv_val,
543 STRLENOF( "9223372036854775807L" ) + 1,
544 "%ld", slap_get_time() + pi->smb_must_change);
545 BER_BVZERO( &keys[1] );
547 ml->sml_desc = ad_sambaPwdMustChange;
548 ml->sml_op = LDAP_MOD_REPLACE;
549 #ifdef SLAP_MOD_INTERNAL
550 ml->sml_flags = SLAP_MOD_INTERNAL;
552 ml->sml_values = keys;
553 ml->sml_nvalues = NULL;
556 #endif /* DO_SAMBA */
557 be_entry_release_r( op, e );
559 return SLAP_CB_CONTINUE;
562 static slap_overinst smbk5pwd;
564 /* back-config stuff */
566 PC_SMB_MUST_CHANGE = 1,
570 static ConfigDriver smbk5pwd_cf_func;
573 * NOTE: uses OID arcs OLcfgOvAt:6 and OLcfgOvOc:6
576 static ConfigTable smbk5pwd_cfats[] = {
577 { "smbk5pwd-enable", "arg",
578 2, 0, 0, ARG_MAGIC|PC_SMB_ENABLE, smbk5pwd_cf_func,
579 "( OLcfgOvAt:6.1 NAME 'olcSmbK5PwdEnable' "
580 "DESC 'Modules to be enabled' "
581 "SYNTAX OMsDirectoryString )", NULL, NULL },
582 { "smbk5pwd-must-change", "time",
583 2, 2, 0, ARG_MAGIC|ARG_INT|PC_SMB_MUST_CHANGE, smbk5pwd_cf_func,
584 "( OLcfgOvAt:6.2 NAME 'olcSmbK5PwdMustChange' "
585 "DESC 'Credentials validity interval' "
586 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
588 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
591 static ConfigOCs smbk5pwd_cfocs[] = {
593 "NAME 'olcSmbK5PwdConfig' "
594 "DESC 'smbk5pwd overlay configuration' "
595 "SUP olcOverlayConfig "
598 "$ olcSmbK5PwdMustChange "
599 ") )", Cft_Overlay, smbk5pwd_cfats },
605 * add here other functionalities; handle their initialization
606 * as appropriate in smbk5pwd_modules_init().
608 static slap_verbmasks smbk5pwd_modules[] = {
609 { BER_BVC( "krb5" ), SMBK5PWD_F_KRB5 },
610 { BER_BVC( "samba" ), SMBK5PWD_F_SAMBA },
615 smbk5pwd_cf_func( ConfigArgs *c )
617 slap_overinst *on = (slap_overinst *)c->bi;
620 smbk5pwd_t *pi = on->on_bi.bi_private;
622 if ( c->op == SLAP_CONFIG_EMIT ) {
624 case PC_SMB_MUST_CHANGE:
626 c->value_int = pi->smb_must_change;
627 #else /* ! DO_SAMBA */
629 #endif /* ! DO_SAMBA */
633 c->rvalue_vals = NULL;
635 mask_to_verbs( smbk5pwd_modules, pi->mode, &c->rvalue_vals );
636 if ( c->rvalue_vals == NULL ) {
648 } else if ( c->op == LDAP_MOD_DELETE ) {
650 case PC_SMB_MUST_CHANGE:
660 m = verb_to_mask( c->line, smbk5pwd_modules );
673 case PC_SMB_MUST_CHANGE:
675 if ( c->value_int < 0 ) {
676 Debug( LDAP_DEBUG_ANY, "%s: smbk5pwd: "
677 "<%s> invalid negative value \"%d\".",
678 c->log, c->argv[ 0 ], 0 );
681 pi->smb_must_change = c->value_int;
682 #else /* ! DO_SAMBA */
683 Debug( LDAP_DEBUG_ANY, "%s: smbk5pwd: "
684 "<%s> only meaningful "
685 "when compiled with -DDO_SAMBA.\n",
686 c->log, c->argv[ 0 ], 0 );
688 #endif /* ! DO_SAMBA */
691 case PC_SMB_ENABLE: {
692 slap_mask_t mode = pi->mode, m;
694 rc = verbs_to_mask( c->argc, c->argv, smbk5pwd_modules, &m );
696 Debug( LDAP_DEBUG_ANY, "%s: smbk5pwd: "
697 "<%s> unknown module \"%s\".\n",
698 c->log, c->argv[ 0 ], c->argv[ rc ] );
702 /* we can hijack the smbk5pwd_t structure because
703 * from within the configuration, this is the only
708 if ( SMBK5PWD_DO_KRB5( pi ) ) {
709 Debug( LDAP_DEBUG_ANY, "%s: smbk5pwd: "
710 "<%s> module \"%s\" only allowed when compiled with -DDO_KRB5.\n",
711 c->log, c->argv[ 0 ], c->argv[ rc ] );
715 #endif /* ! DO_KRB5 */
718 if ( SMBK5PWD_DO_SAMBA( pi ) ) {
719 Debug( LDAP_DEBUG_ANY, "%s: smbk5pwd: "
720 "<%s> module \"%s\" only allowed when compiled with -DDO_SAMBA.\n",
721 c->log, c->argv[ 0 ], c->argv[ rc ] );
725 #endif /* ! DO_SAMBA */
728 BackendDB db = *c->be;
730 /* Re-initialize the module, because
731 * the configuration might have changed */
732 db.bd_info = (BackendInfo *)on;
733 rc = smbk5pwd_modules_init( pi );
750 smbk5pwd_modules_init( smbk5pwd_t *pi )
756 if ( SMBK5PWD_DO_KRB5( pi ) && oc_krb5KDCEntry == NULL ) {
758 extern HDB *_kadm5_s_get_db(void *);
760 /* Make sure all of our necessary schema items are loaded */
761 oc_krb5KDCEntry = oc_find( "krb5KDCEntry" );
762 if ( !oc_krb5KDCEntry ) {
763 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
764 "unable to find \"krb5KDCEntry\" objectClass.\n",
771 rc = slap_str2ad( "krb5Key", &ad_krb5Key, &text );
772 if ( rc != LDAP_SUCCESS ) {
773 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
774 "unable to find \"krb5Key\" attributeType: %s (%d).\n",
779 ad_krb5KeyVersionNumber = NULL;
780 rc = slap_str2ad( "krb5KeyVersionNumber", &ad_krb5KeyVersionNumber, &text );
781 if ( rc != LDAP_SUCCESS ) {
782 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
783 "unable to find \"krb5KeyVersionNumber\" attributeType: %s (%d).\n",
788 ad_krb5PrincipalName = NULL;
789 rc = slap_str2ad( "krb5PrincipalName", &ad_krb5PrincipalName, &text );
790 if ( rc != LDAP_SUCCESS ) {
791 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
792 "unable to find \"krb5PrincipalName\" attributeType: %s (%d).\n",
797 /* Initialize Kerberos context */
798 ret = krb5_init_context(&context);
800 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
801 "unable to initialize krb5 context.\n",
807 if ( context == NULL ) {
808 ret = kadm5_s_init_with_password_ctx( context,
812 &conf, 0, 0, &kadm_context );
814 db = _kadm5_s_get_db( kadm_context );
819 oc_krb5KDCEntry = NULL;
827 if ( SMBK5PWD_DO_SAMBA( pi ) && oc_sambaSamAccount == NULL ) {
828 oc_sambaSamAccount = oc_find( "sambaSamAccount" );
829 if ( !oc_sambaSamAccount ) {
830 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
831 "unable to find \"sambaSamAccount\" objectClass.\n",
837 ad_sambaLMPassword = NULL;
838 rc = slap_str2ad( "sambaLMPassword", &ad_sambaLMPassword, &text );
839 if ( rc != LDAP_SUCCESS ) {
840 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
841 "unable to find \"sambaLMPassword\" attributeType: %s (%d).\n",
846 ad_sambaNTPassword = NULL;
847 rc = slap_str2ad( "sambaNTPassword", &ad_sambaNTPassword, &text );
848 if ( rc != LDAP_SUCCESS ) {
849 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
850 "unable to find \"sambaNTPassword\" attributeType: %s (%d).\n",
855 ad_sambaPwdLastSet = NULL;
856 if ( rc != LDAP_SUCCESS ) {
857 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
858 "unable to find \"sambaPwdLastSet\" attributeType: %s (%d).\n",
863 ad_sambaPwdMustChange = NULL;
864 if ( rc != LDAP_SUCCESS ) {
865 Debug( LDAP_DEBUG_ANY, "smbk5pwd: "
866 "unable to find \"sambaPwdMustChange\" attributeType: %s (%d).\n",
873 oc_sambaSamAccount = NULL;
879 #endif /* DO_SAMBA */
885 smbk5pwd_db_init(BackendDB *be)
887 slap_overinst *on = (slap_overinst *)be->bd_info;
890 pi = ch_calloc( 1, sizeof( smbk5pwd_t ) );
894 on->on_bi.bi_private = (void *)pi;
900 smbk5pwd_db_open(BackendDB *be)
902 slap_overinst *on = (slap_overinst *)be->bd_info;
903 smbk5pwd_t *pi = (smbk5pwd_t *)on->on_bi.bi_private;
907 if ( pi->mode == 0 ) {
908 pi->mode = SMBK5PWD_F_ALL;
911 rc = smbk5pwd_modules_init( pi );
920 smbk5pwd_db_destroy(BackendDB *be)
922 slap_overinst *on = (slap_overinst *)be->bd_info;
923 smbk5pwd_t *pi = (smbk5pwd_t *)on->on_bi.bi_private;
933 smbk5pwd_initialize(void)
937 smbk5pwd.on_bi.bi_type = "smbk5pwd";
939 smbk5pwd.on_bi.bi_db_init = smbk5pwd_db_init;
940 smbk5pwd.on_bi.bi_db_open = smbk5pwd_db_open;
941 smbk5pwd.on_bi.bi_db_destroy = smbk5pwd_db_destroy;
943 smbk5pwd.on_bi.bi_extended = smbk5pwd_exop_passwd;
946 smbk5pwd.on_bi.bi_op_bind = smbk5pwd_op_bind;
948 lutil_passwd_add( (struct berval *)&k5key_scheme, k5key_chk, k5key_hash );
951 smbk5pwd.on_bi.bi_cf_ocs = smbk5pwd_cfocs;
953 rc = config_register_schema( smbk5pwd_cfats, smbk5pwd_cfocs );
958 return overlay_register( &smbk5pwd );
961 #if SLAPD_OVER_SMBK5PWD == SLAPD_MOD_DYNAMIC
962 int init_module(int argc, char *argv[]) {
963 return smbk5pwd_initialize();
967 #endif /* defined(SLAPD_OVER_SMBK5PWD) */