1 /* extended.c - ldbm backend extended routines */
4 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
17 #include "proto-back-ldbm.h"
20 ldbm_back_exop_passwd(
25 struct berval *reqdata,
26 struct berval **rspdata,
30 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
31 int rc = LDAP_OPERATIONS_ERROR;
33 struct berval *cred = NULL;
35 assert( oid != NULL );
36 assert( strcmp( LDAP_EXOP_X_MODIFY_PASSWD, oid ) == 0 );
38 Debug( LDAP_DEBUG_ARGS, "==> ldbm_back_exop_passwd: dn: %s\n",
42 cred = slap_passwd_generate( reqdata );
43 if( cred == NULL || cred->bv_len == 0 ) {
44 *text = ch_strdup("password generation failed");
45 return LDAP_OPERATIONS_ERROR;
48 Debug( LDAP_DEBUG_TRACE, "passwd: %s\n", cred->bv_val, 0, 0 );
50 e = dn2entry_w( be, op->o_ndn, NULL );
53 *text = ch_strdup("could not locate authorization entry");
54 return LDAP_OPERATIONS_ERROR;
57 if( ! access_allowed( be, conn, op, e, "entry", NULL, ACL_WRITE ) ) {
58 *text = ch_strdup("access to authorization entry denied");
59 rc = LDAP_INSUFFICIENT_ACCESS;
63 if( is_entry_alias( e ) ) {
64 /* entry is an alias, don't allow operation */
65 *text = ch_strdup("authorization entry is alias");
66 rc = LDAP_ALIAS_PROBLEM;
70 if( is_entry_referral( e ) ) {
71 /* entry is an referral, don't allow operation */
72 *text = ch_strdup("authorization entry is referral");
78 struct berval *vals[2];
83 ml.ml_type = ch_strdup("userPassword");
85 ml.ml_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
88 rc = ldbm_modify_internal( be,
89 conn, op, op->o_ndn, &ml, e );
94 if( rc == LDAP_SUCCESS ) {
95 /* change the entry itself */
96 if( id2entry_add( be, e ) != 0 ) {
97 rc = LDAP_OPERATIONS_ERROR;
102 cache_return_entry_w( &li->li_cache, e );