/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
* Portions Copyright 1997,2002-2003 IBM Corporation.
* All rights reserved.
*
#include <ac/stdarg.h>
#include <ac/ctype.h>
#include <ac/unistd.h>
-#include <ldap_pvt.h>
#include <slap.h>
#include <slapi.h>
#endif
}
-int
+long
slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type )
{
#ifdef LDAP_SLAPI
#endif
}
-int
+unsigned int
slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type )
{
#ifdef LDAP_SLAPI
#endif
}
-int
+unsigned long
slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type )
{
#ifdef LDAP_SLAPI
Attribute *a;
int i;
- for ( size = 0, a = e->e_attrs; a != NULL; a->a_next ) {
+ for ( size = 0, a = e->e_attrs; a != NULL; a = a->a_next ) {
for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
size += a->a_vals[i].bv_len + 1;
}
if ( slapi_mask & SLAPI_OPERATION_ABANDON )
*slap_mask |= SLAP_CTRL_ABANDON;
- *slap_mask |= SLAP_CTRL_FRONTEND;
+ *slap_mask |= SLAP_CTRL_GLOBAL;
}
static int
slapiControlOp2SlapControlMask( controlops, &controlmask );
- register_supported_control( controloid, controlmask, NULL, slapi_int_parse_control );
+ register_supported_control( controloid, controlmask, NULL, slapi_int_parse_control, NULL );
#endif /* LDAP_SLAPI */
}
rs.sr_ref = NULL;
rs.sr_ctrls = ectrls;
rs.sr_attrs = an;
+ rs.sr_operational_attrs = NULL;
rs.sr_entry = e;
rs.sr_v2ref = NULL;
rs.sr_flags = 0;
rs.sr_ctrls = ectrls;
rs.sr_attrs = NULL;
+ rs.sr_operational_attrs = NULL;
rs.sr_entry = e;
if ( v2refs != NULL ) {
int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v )
{
#ifdef LDAP_SLAPI
- /*
- * FIXME: here we may lose alignment between a_vals/a_nvals
- */
- return value_add_one( &a->a_vals, (Slapi_Value *)v );
+ struct berval nval;
+ struct berval *nvalp;
+ int rc;
+ AttributeDescription *desc = a->a_desc;
+
+ if ( desc->ad_type->sat_equality &&
+ desc->ad_type->sat_equality->smr_normalize ) {
+ rc = (*desc->ad_type->sat_equality->smr_normalize)(
+ SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+ desc->ad_type->sat_syntax,
+ desc->ad_type->sat_equality,
+ (Slapi_Value *)v, &nval, NULL );
+ if ( rc != LDAP_SUCCESS ) {
+ return rc;
+ }
+ nvalp = &nval;
+ } else {
+ nvalp = NULL;
+ }
+
+ rc = value_add_one( &a->a_vals, (Slapi_Value *)v );
+ if ( rc == 0 && nvalp != NULL ) {
+ rc = value_add_one( &a->a_nvals, nvalp );
+ } else {
+ a->a_nvals = a->a_vals;
+ }
+
+ if ( nvalp != NULL ) {
+ slapi_ch_free_string( &nval.bv_val );
+ }
+
+ return rc;
#else
return -1;
#endif
Modifications *modlist = NULL, **modtail;
LDAPMod **modp;
+ if ( mods == NULL ) {
+ return NULL;
+ }
+
modtail = &modlist;
for( modp = mods; *modp != NULL; modp++ ) {
return 1;
}
- if ( !c->cac_attrsonly ) {
+ if ( !c->cac_attrsonly && a->a_vals != NULL ) {
for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
if ( !access_allowed( op, e,
desc, &a->a_vals[i], ACL_READ, &c->cac_acl_state)) {
LDAPDN dn;
int rc;
int i = 0, match = 0;
- char *dn_str;
- dn_str = slapi_entry_get_dn( (Slapi_Entry *) e );
- rc = ldap_str2dn( dn_str, &dn, LDAP_DN_FORMAT_LDAPV3 );
+ rc = ldap_bv2dn( &((Entry *)e)->e_name, &dn, LDAP_DN_FORMAT_LDAPV3 );
if ( rc != LDAP_SUCCESS ) {
return 0;
}
#ifdef LDAP_SLAPI
LDAPDN dn;
int i, rc;
- char *dn_str;
- dn_str = slapi_entry_get_dn( e );
- rc = ldap_str2dn( dn_str, &dn, LDAP_DN_FORMAT_LDAPV3 );
+ rc = ldap_bv2dn( &e->e_name, &dn, LDAP_DN_FORMAT_LDAPV3 );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
#endif /* LDAP_SLAPI */
}
+LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared )
+{
+#ifdef LDAP_SLAPI
+ LDAP *ld;
+ char *url;
+ size_t size;
+ int rc;
+
+ size = sizeof("ldap:///");
+ if ( secure )
+ size++;
+ size += strlen( ldaphost );
+ if ( ldapport != 0 )
+ size += 32;
+
+ url = slapi_ch_malloc( size );
+
+ if ( ldapport != 0 ) {
+ sprintf( url, "ldap%s://%s:%d/", ( secure ? "s" : "" ), ldaphost, ldapport );
+ } else {
+ sprintf( url, "ldap%s://%s/", ( secure ? "s" : "" ), ldaphost );
+ }
+
+ rc = ldap_initialize( &ld, url );
+
+ slapi_ch_free_string( &url );
+
+ return ( rc == LDAP_SUCCESS ) ? ld : NULL;
+#else
+ return NULL;
+#endif /* LDAP_SLAPI */
+}
+
+void slapi_ldap_unbind( LDAP *ld )
+{
+#ifdef LDAP_SLAPI
+ ldap_unbind( ld );
+#endif /* LDAP_SLAPI */
+}
+
+int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags )
+{
+#ifdef LDAP_SLAPI
+ if ( be == NULL )
+ return LDAP_PARAM_ERROR;
+
+ *flags = SLAP_DBFLAGS(be);
+
+ return LDAP_SUCCESS;
+#else
+ return -1;
+#endif /* LDAP_SLAPI */
+}
+