2004-01-20 06:13:15 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
|
|
|
* Copyright 1999-2004 The OpenLDAP Foundation.
|
|
|
|
* Portions Copyright 1999 Dmitry Kovalev.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Dmitry Kovalev for inclusion
|
|
|
|
* by OpenLDAP Software.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#ifdef SLAPD_SQL
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "proto-sql.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sets the supported operational attributes (if required)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
backsql_operational(
|
|
|
|
Operation *op,
|
2004-07-19 05:44:29 +08:00
|
|
|
SlapReply *rs )
|
2004-01-20 06:13:15 +08:00
|
|
|
{
|
|
|
|
|
2004-07-19 05:44:29 +08:00
|
|
|
backsql_info *bi = (backsql_info*)op->o_bd->be_private;
|
|
|
|
SQLHDBC dbh = SQL_NULL_HDBC;
|
|
|
|
int rc = 0;
|
|
|
|
Attribute **ap;
|
2004-01-20 06:13:15 +08:00
|
|
|
|
2004-04-10 17:33:55 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry \"%s\"\n",
|
2004-01-20 06:13:15 +08:00
|
|
|
rs->sr_entry->e_nname.bv_val, 0, 0 );
|
|
|
|
|
2004-07-19 05:44:29 +08:00
|
|
|
for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
|
|
|
|
/* just count */ ;
|
2004-01-20 06:13:15 +08:00
|
|
|
|
2004-07-26 07:16:40 +08:00
|
|
|
if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
|
2004-01-20 06:13:15 +08:00
|
|
|
&& attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL ) {
|
|
|
|
|
|
|
|
rc = backsql_get_db_conn( op, &dbh );
|
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
|
|
|
|
"could not get connection handle - exiting\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = backsql_has_children( bi, dbh, &rs->sr_entry->e_nname );
|
|
|
|
|
|
|
|
switch( rc ) {
|
|
|
|
case LDAP_COMPARE_TRUE:
|
|
|
|
case LDAP_COMPARE_FALSE:
|
2004-07-19 05:44:29 +08:00
|
|
|
*ap = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
|
|
|
|
assert( *ap );
|
|
|
|
ap = &(*ap)->a_next;
|
2004-01-20 06:13:15 +08:00
|
|
|
rc = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
|
|
|
|
"has_children failed( %d)\n", rc, 0, 0 );
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "<==backsql_operational()\n", 0, 0, 0);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SLAPD_SQL */
|
|
|
|
|