/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
* Portions Copyright 2004 Howard Chu, Symas Corporation.
* Portions Copyright 2004 Hewlett-Packard Company.
* All rights reserved.
} pw_conn;
static pw_conn *pwcons;
+static int ppolicy_cid;
typedef struct pass_policy {
AttributeDescription *ad; /* attribute to which the policy applies */
"EQUALITY generalizedTimeMatch "
"ORDERING generalizedTimeOrderingMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE USAGE directoryOperation NO-USER-MODIFICATION )",
&ad_pwdChangedTime },
{ "( 1.3.6.1.4.1.42.2.27.8.1.17 "
"NAME ( 'pwdAccountLockedTime' ) "
"EQUALITY generalizedTimeMatch "
"ORDERING generalizedTimeOrderingMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE USAGE directoryOperation NO-USER-MODIFICATION )",
&ad_pwdExpirationWarned },
{ "( 1.3.6.1.4.1.42.2.27.8.1.19 "
"NAME ( 'pwdFailureTime' ) "
"DESC 'The history of users passwords' "
"EQUALITY octetStringMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
- "USAGE directoryOperation )",
+ "USAGE directoryOperation NO-USER-MODIFICATION )",
&ad_pwdHistory },
{ "( 1.3.6.1.4.1.42.2.27.8.1.21 "
"NAME ( 'pwdGraceUseTime' ) "
"DESC 'The timestamps of the grace login once the password has expired' "
"EQUALITY generalizedTimeMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "USAGE directoryOperation )",
+ "USAGE directoryOperation NO-USER-MODIFICATION )",
&ad_pwdGraceUseTime },
{ "( 1.3.6.1.4.1.42.2.27.8.1.22 "
"NAME ( 'pwdReset' ) "
"DESC 'The indication that the password has been reset' "
"EQUALITY booleanMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE USAGE directoryOperation NO-USER-MODIFICATION )",
&ad_pwdReset },
{ "( 1.3.6.1.4.1.42.2.27.8.1.23 "
"NAME ( 'pwdPolicySubentry' ) "
const char *text;
AttributeDescription *ad;
struct berval bv;
- void *opr = op->o_private;
memset( pp, 0, sizeof(PassPolicy) );
}
}
- /* back-bdb stores lock info in o_private */
- op->o_private = NULL;
op->o_bd->bd_info = (BackendInfo *)on->on_info;
rc = be_entry_get_rw( op, vals, NULL, NULL, 0, &pe );
op->o_bd->bd_info = (BackendInfo *)on;
be_entry_release_r( op, pe );
op->o_bd->bd_info = (BackendInfo *)on;
- op->o_private = opr;
return;
defaultpol:
Debug( LDAP_DEBUG_ANY,
"ppolicy_get: using default policy\n", 0, 0, 0 );
- op->o_private = opr;
return;
}
pp->pwdCheckModule, err, 0 );
ok = LDAP_OTHER; /* internal error */
} else {
- int (*prog)( char *passwd, char **text, Attribute *attrs );
+ int (*prog)( char *passwd, char **text, Entry *ent );
if ((prog = lt_dlsym( mod, "check_password" )) == NULL) {
err = lt_dlerror();
char *txt = NULL;
ldap_pvt_thread_mutex_lock( &chk_syntax_mutex );
- ok = prog( cred->bv_val, &txt, e ? e->e_attrs : NULL );
+ ok = prog( cred->bv_val, &txt, e );
ldap_pvt_thread_mutex_unlock( &chk_syntax_mutex );
if (txt) {
Debug(LDAP_DEBUG_ANY,
op->o_callback->sc_next = cb;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) )
- {
- ppb->send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ ppb->send_ctrl = 1;
}
op->o_bd->bd_info = (BackendInfo *)on;
int i, send_ctrl = 0;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
if ( op->o_conn && pwcons[op->o_conn->c_conn_idx].restrict ) {
LDAPPasswordPolicyError pErr = PP_noError;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
rc = check_password_quality( bv, &pp, &pErr, op->ora_e );
if (rc != LDAP_SUCCESS) {
}
}
/* If password aging is in effect, set the pwdChangedTime */
- if (( pp.pwdMaxAge || pp.pwdMinAge ) && !be_isupdate( op )) {
+ if (( pp.pwdMaxAge || pp.pwdMinAge ) && !be_shadow_update( op )) {
struct berval timestamp;
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
struct tm *ltm;
PassPolicy pp;
Modifications *mods = NULL, *modtail, *ml, *delmod, *addmod;
Attribute *pa, *ha, *ra, at;
- int repl_user = be_isupdate( op );
const char *txt;
pw_hist *tl = NULL, *p;
int zapReset, send_ctrl = 0;
if ( rc != LDAP_SUCCESS ) return SLAP_CB_CONTINUE;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
/* See if this is a pwdModify exop. If so, we can
const char *txt;
bv = oldpw.bv_val ? &oldpw : delmod->sml_values;
- rc = slap_passwd_check( op->o_conn, pa, bv, &txt );
+ /* FIXME: no access checking? */
+ rc = slap_passwd_check( op, NULL, pa, bv, &txt );
if (rc != LDAP_SUCCESS) {
Debug( LDAP_DEBUG_TRACE,
"old password check failed: %s\n", txt, 0, 0 );
/*
* Last check - the password history.
*/
- if (slap_passwd_check( op->o_conn, pa, bv, &txt ) == LDAP_SUCCESS) {
+ /* FIXME: no access checking? */
+ if (slap_passwd_check( op, NULL, pa, bv, &txt ) == LDAP_SUCCESS) {
/*
* This is bad - it means that the user is attempting
* to set the password to the same as the old one.
cr[1].bv_val = NULL;
for(p=tl; p; p=p->next) {
cr[0] = p->pw;
- rc = slap_passwd_check( op->o_conn, &at, bv, &txt );
+ /* FIXME: no access checking? */
+ rc = slap_passwd_check( op, NULL, &at, bv, &txt );
if (rc != LDAP_SUCCESS) continue;
}
do_modify:
- if ((pwmod) && (!repl_user)) {
+ if ((pwmod) && (!be_shadow_update( op ))) {
struct berval timestamp;
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
struct tm *ltm;
rs->sr_text = "passwordPolicyRequest control invalid criticality";
return LDAP_PROTOCOL_ERROR;
}
+ op->o_ctrlflag[ppolicy_cid] = SLAP_CONTROL_NONCRITICAL;
return LDAP_SUCCESS;
}
return 0;
}
+static int
+ppolicy_db_open(
+ BackendDB *be
+)
+{
+ return overlay_register_control( be, LDAP_CONTROL_PASSWORDPOLICYREQUEST );
+}
+
static int
ppolicy_close(
BackendDB *be
ldap_scherr2str(code), err );
return code;
}
- code = at_add( at, &err );
+ code = at_add( at, 0, NULL, &err );
if ( !code ) {
slap_str2ad( at->at_names[0], pwd_OpSchema[i].ad, &err );
}
}
code = register_supported_control( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
- SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY, extops,
- ppolicy_parseCtrl );
+ SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY|SLAP_CTRL_HIDE, extops,
+ ppolicy_parseCtrl, &ppolicy_cid );
if ( code != LDAP_SUCCESS ) {
fprintf( stderr, "Failed to register control %d\n", code );
return code;
ppolicy.on_bi.bi_type = "ppolicy";
ppolicy.on_bi.bi_db_init = ppolicy_db_init;
+ ppolicy.on_bi.bi_db_open = ppolicy_db_open;
ppolicy.on_bi.bi_db_config = ppolicy_config;
ppolicy.on_bi.bi_db_close = ppolicy_close;