本文整理汇总了C++中dnParent函数的典型用法代码示例。如果您正苦于以下问题:C++ dnParent函数的具体用法?C++ dnParent怎么用?C++ dnParent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dnParent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: slapi_sdn_get_parent
void slapi_sdn_get_parent( const Slapi_DN *sdn, Slapi_DN *sdn_parent )
{
struct berval parent_dn;
if ( !(sdn->flag & FLAG_DN) ) {
dnParent( (struct berval *)&sdn->ndn, &parent_dn );
slapi_sdn_set_ndn_byval( sdn_parent, parent_dn.bv_val );
} else {
dnParent( (struct berval *)&sdn->dn, &parent_dn );
slapi_sdn_set_dn_byval( sdn_parent, parent_dn.bv_val );
}
}
开发者ID:Distrotech,项目名称:openldap,代码行数:12,代码来源:slapi_dn.c
示例2: slapi_sdn_isgrandparent
int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child )
{
Slapi_DN child_grandparent;
slapi_sdn_get_ndn( child );
slapi_sdn_init( &child_grandparent );
dnParent( (struct berval *)&child->ndn, &child_grandparent.ndn );
if ( child_grandparent.ndn.bv_len == 0 ) {
return 0;
}
dnParent( &child_grandparent.ndn, &child_grandparent.ndn );
return ( slapi_sdn_compare( parent, &child_grandparent ) == 0 );
}
开发者ID:Distrotech,项目名称:openldap,代码行数:16,代码来源:slapi_dn.c
示例3: monitor_cache_dn2entry
/*
* If the entry exists in cache, it is returned in locked status;
* otherwise, if the parent exists, if it may generate volatile
* descendants an attempt to generate the required entry is
* performed and, if successful, the entry is returned
*/
int
monitor_cache_dn2entry(
Operation *op,
SlapReply *rs,
struct berval *ndn,
Entry **ep,
Entry **matched )
{
monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
int rc;
struct berval p_ndn = BER_BVNULL;
Entry *e_parent;
monitor_entry_t *mp;
assert( mi != NULL );
assert( ndn != NULL );
assert( ep != NULL );
assert( matched != NULL );
*matched = NULL;
if ( !dnIsSuffix( ndn, &op->o_bd->be_nsuffix[ 0 ] ) ) {
return( -1 );
}
rc = monitor_cache_get( mi, ndn, ep );
if ( !rc && *ep != NULL ) {
return( 0 );
}
/* try with parent/ancestors */
if ( BER_BVISNULL( ndn ) ) {
BER_BVSTR( &p_ndn, "" );
} else {
dnParent( ndn, &p_ndn );
}
rc = monitor_cache_dn2entry( op, rs, &p_ndn, &e_parent, matched );
if ( rc || e_parent == NULL ) {
return( -1 );
}
mp = ( monitor_entry_t * )e_parent->e_private;
rc = -1;
if ( mp->mp_flags & MONITOR_F_VOLATILE_CH ) {
/* parent entry generates volatile children */
rc = monitor_entry_create( op, rs, ndn, e_parent, ep );
}
if ( !rc ) {
monitor_cache_lock( *ep );
monitor_cache_release( mi, e_parent );
} else {
*matched = e_parent;
}
return( rc );
}
开发者ID:Joywar,项目名称:openldap,代码行数:66,代码来源:cache.c
示例4: set_parent
static BerVarray
set_parent( SetCookie *cp, BerVarray set, int level )
{
int i, j, last;
struct berval bv;
BerVarray nset;
if ( set == NULL ) {
set = cp->set_op->o_tmpcalloc( 1, sizeof( struct berval ),
cp->set_op->o_tmpmemctx );
if ( set != NULL ) {
BER_BVZERO( &set[ 0 ] );
}
return set;
}
if ( BER_BVISNULL( &set[ 0 ] ) ) {
return set;
}
nset = cp->set_op->o_tmpcalloc( slap_set_size( set ) + 1, sizeof( struct berval ), cp->set_op->o_tmpmemctx );
if ( nset == NULL ) {
ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
return NULL;
}
BER_BVZERO( &nset[ 0 ] );
last = 0;
for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ ) {
bv = set[ i ];
for ( j = 0 ; j < level ; j++ ) {
dnParent( &bv, &bv );
}
for ( j = 0; !BER_BVISNULL( &nset[ j ] ); j++ ) {
if ( bvmatch( &bv, &nset[ j ] ) )
{
break;
}
}
if ( BER_BVISNULL( &nset[ j ] ) ) {
ber_dupbv_x( &nset[ last ], &bv, cp->set_op->o_tmpmemctx );
last++;
}
}
BER_BVZERO( &nset[ last ] );
ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
return nset;
}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:55,代码来源:sets.c
示例5: slapi_sdn_isparent
int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child )
{
Slapi_DN child_parent;
slapi_sdn_get_ndn( child );
slapi_sdn_init( &child_parent );
dnParent( (struct berval *)&child->ndn, &child_parent.ndn );
return ( slapi_sdn_compare( parent, &child_parent ) == 0 );
}
开发者ID:Distrotech,项目名称:openldap,代码行数:11,代码来源:slapi_dn.c
示例6: constraint_check_restrict
static int
constraint_check_restrict( Operation *op, constraint *c, Entry *e )
{
assert( c->restrict_lud != NULL );
if ( c->restrict_lud->lud_dn != NULL ) {
int diff = e->e_nname.bv_len - c->restrict_ndn.bv_len;
if ( diff < 0 ) {
return 0;
}
if ( c->restrict_lud->lud_scope == LDAP_SCOPE_BASE ) {
return bvmatch( &e->e_nname, &c->restrict_ndn );
}
if ( !dnIsSuffix( &e->e_nname, &c->restrict_ndn ) ) {
return 0;
}
if ( c->restrict_lud->lud_scope != LDAP_SCOPE_SUBTREE ) {
struct berval pdn;
if ( diff == 0 ) {
return 0;
}
dnParent( &e->e_nname, &pdn );
if ( c->restrict_lud->lud_scope == LDAP_SCOPE_ONELEVEL
&& pdn.bv_len != c->restrict_ndn.bv_len )
{
return 0;
}
}
}
if ( c->restrict_filter != NULL ) {
int rc;
struct berval save_dn = op->o_dn, save_ndn = op->o_ndn;
op->o_dn = op->o_bd->be_rootdn;
op->o_ndn = op->o_bd->be_rootndn;
rc = test_filter( op, e, c->restrict_filter );
op->o_dn = save_dn;
op->o_ndn = save_ndn;
if ( rc != LDAP_COMPARE_TRUE ) {
return 0;
}
}
return 1;
}
开发者ID:dago,项目名称:openldap,代码行数:54,代码来源:constraint.c
示例7: glue_parent
void glue_parent(Operation *op) {
Operation nop = *op;
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
struct berval ndn = BER_BVNULL;
Attribute *a;
Entry *e;
struct berval pdn;
dnParent( &op->o_req_ndn, &pdn );
ber_dupbv_x( &ndn, &pdn, op->o_tmpmemctx );
Debug(LDAP_DEBUG_TRACE, "=> glue_parent: fabricating glue for <%s>\n", ndn.bv_val, 0, 0);
e = entry_alloc();
e->e_id = NOID;
ber_dupbv(&e->e_name, &ndn);
ber_dupbv(&e->e_nname, &ndn);
a = attr_alloc( slap_schema.si_ad_objectClass );
a->a_numvals = 2;
a->a_vals = ch_malloc(sizeof(struct berval) * 3);
ber_dupbv(&a->a_vals[0], &glue[0]);
ber_dupbv(&a->a_vals[1], &glue[1]);
ber_dupbv(&a->a_vals[2], &glue[2]);
a->a_nvals = a->a_vals;
a->a_next = e->e_attrs;
e->e_attrs = a;
a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
a->a_numvals = 1;
a->a_vals = ch_malloc(sizeof(struct berval) * 2);
ber_dupbv(&a->a_vals[0], &glue[1]);
ber_dupbv(&a->a_vals[1], &glue[2]);
a->a_nvals = a->a_vals;
a->a_next = e->e_attrs;
e->e_attrs = a;
nop.o_req_dn = ndn;
nop.o_req_ndn = ndn;
nop.ora_e = e;
nop.o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig;
syncrepl_add_glue(&nop, e);
nop.o_bd->bd_info = (BackendInfo *) on;
op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
return;
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:49,代码来源:translucent.c
示例8: dnIsWithinScope
/*
* In place; assumes:
* - ndn is normalized
* - nbase is normalized
* - dnIsSuffix( ndn, nbase ) == TRUE
* - LDAP_SCOPE_DEFAULT == LDAP_SCOPE_SUBTREE
*/
int
dnIsWithinScope( struct berval *ndn, struct berval *nbase, int scope )
{
assert( ndn != NULL );
assert( nbase != NULL );
assert( !BER_BVISNULL( ndn ) );
assert( !BER_BVISNULL( nbase ) );
switch ( scope ) {
case LDAP_SCOPE_DEFAULT:
case LDAP_SCOPE_SUBTREE:
break;
case LDAP_SCOPE_BASE:
if ( ndn->bv_len != nbase->bv_len ) {
return 0;
}
break;
case LDAP_SCOPE_ONELEVEL: {
struct berval pndn;
dnParent( ndn, &pndn );
if ( pndn.bv_len != nbase->bv_len ) {
return 0;
}
}
break;
case LDAP_SCOPE_SUBORDINATE:
if ( ndn->bv_len == nbase->bv_len ) {
return 0;
}
break;
/* unknown scope */
default:
return -1;
}
return 1;
}
开发者ID:wepe912,项目名称:openldap,代码行数:48,代码来源:dn.c
示例9: fe_op_delete
int
fe_op_delete( Operation *op, SlapReply *rs )
{
struct berval pdn = BER_BVNULL;
BackendDB *op_be, *bd = op->o_bd;
/*
* We could be serving multiple database backends. Select the
* appropriate one, or send a referral to our "referral server"
* if we don't hold it.
*/
op->o_bd = select_backend( &op->o_req_ndn, 1 );
if ( op->o_bd == NULL ) {
op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral;
if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
} else {
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" );
}
goto cleanup;
}
/* If we've got a glued backend, check the real backend */
op_be = op->o_bd;
if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
op->o_bd = select_backend( &op->o_req_ndn, 0 );
}
/* check restrictions */
if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
goto cleanup;
}
/* check for referrals */
if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
goto cleanup;
}
/*
* do the delete if 1 && (2 || 3)
* 1) there is a delete function implemented in this backend;
* 2) this backend is master for what it holds;
* 3) it's a replica and the dn supplied is the update_ndn.
*/
if ( op->o_bd->be_delete ) {
/* do the update here */
int repl_user = be_isupdate( op );
if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) {
struct berval org_req_dn = BER_BVNULL;
struct berval org_req_ndn = BER_BVNULL;
struct berval org_dn = BER_BVNULL;
struct berval org_ndn = BER_BVNULL;
int org_managedsait;
op->o_bd = op_be;
op->o_bd->be_delete( op, rs );
org_req_dn = op->o_req_dn;
org_req_ndn = op->o_req_ndn;
org_dn = op->o_dn;
org_ndn = op->o_ndn;
org_managedsait = get_manageDSAit( op );
op->o_dn = op->o_bd->be_rootdn;
op->o_ndn = op->o_bd->be_rootndn;
op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
while ( rs->sr_err == LDAP_SUCCESS &&
op->o_delete_glue_parent )
{
op->o_delete_glue_parent = 0;
if ( !be_issuffix( op->o_bd, &op->o_req_ndn )) {
slap_callback cb = { NULL, NULL, NULL, NULL };
cb.sc_response = slap_null_cb;
dnParent( &op->o_req_ndn, &pdn );
op->o_req_dn = pdn;
op->o_req_ndn = pdn;
op->o_callback = &cb;
op->o_bd->be_delete( op, rs );
} else {
break;
}
}
op->o_managedsait = org_managedsait;
op->o_dn = org_dn;
op->o_ndn = org_ndn;
op->o_req_dn = org_req_dn;
op->o_req_ndn = org_req_ndn;
op->o_delete_glue_parent = 0;
} else {
//.........这里部分代码省略.........
开发者ID:dago,项目名称:openldap,代码行数:101,代码来源:delete.c
示例10: passwd_back_search
//.........这里部分代码省略.........
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
goto done;
}
if ( test_filter( op, &e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
/* check size limit */
if ( --op->ors_slimit == -1 ) {
send_ldap_error( op, rs, LDAP_SIZELIMIT_EXCEEDED, NULL );
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
return( 0 );
}
rs->sr_entry = &e;
rs->sr_attrs = op->ors_attrs;
rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
rs->sr_flags = 0;
rs->sr_entry = NULL;
}
entry_clean( &e );
}
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
}
} else {
char *next;
Entry e = { 0 };
int rc;
if (! be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
dnParent( &op->o_req_ndn, &parent );
}
/* This backend is only one layer deep. Don't answer requests for
* anything deeper than that.
*/
if( !be_issuffix( op->o_bd, &parent ) ) {
int i;
for( i=0; op->o_bd->be_nsuffix[i].bv_val != NULL; i++ ) {
if( dnIsSuffix( &op->o_req_ndn, &op->o_bd->be_nsuffix[i] ) ) {
rs->sr_matched = op->o_bd->be_suffix[i].bv_val;
break;
}
}
rs->sr_err = LDAP_NO_SUCH_OBJECT;
goto done;
}
if( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
goto done;
}
if ( ldap_bv2rdn( &op->o_req_dn, &rdn, &next,
LDAP_DN_FORMAT_LDAP ))
{
rs->sr_err = LDAP_OTHER;
goto done;
}
ldap_pvt_thread_mutex_lock( &passwd_mutex );
pw_start( op->o_bd );
pw = getpwnam( rdn[0]->la_value.bv_val );
if ( pw == NULL ) {
开发者ID:winlibs,项目名称:openldap,代码行数:67,代码来源:search.c
示例11: retcode_op_func
static int
retcode_op_func( Operation *op, SlapReply *rs )
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
retcode_t *rd = (retcode_t *)on->on_bi.bi_private;
retcode_item_t *rdi;
struct berval nrdn, npdn;
slap_callback *cb = NULL;
/* sleep as required */
retcode_sleep( rd->rd_sleep );
if ( !dnIsSuffix( &op->o_req_ndn, &rd->rd_npdn ) ) {
if ( RETCODE_INDIR( rd ) ) {
switch ( op->o_tag ) {
case LDAP_REQ_ADD:
return retcode_op_add( op, rs );
case LDAP_REQ_BIND:
/* skip if rootdn */
/* FIXME: better give the db a chance? */
if ( be_isroot_pw( op ) ) {
return LDAP_SUCCESS;
}
return retcode_op_internal( op, rs );
case LDAP_REQ_SEARCH:
if ( op->ors_scope == LDAP_SCOPE_BASE ) {
rs->sr_err = retcode_op_internal( op, rs );
switch ( rs->sr_err ) {
case SLAP_CB_CONTINUE:
if ( rs->sr_nentries == 0 ) {
break;
}
rs->sr_err = LDAP_SUCCESS;
/* fallthru */
default:
send_ldap_result( op, rs );
break;
}
return rs->sr_err;
}
break;
case LDAP_REQ_MODIFY:
case LDAP_REQ_DELETE:
case LDAP_REQ_MODRDN:
case LDAP_REQ_COMPARE:
return retcode_op_internal( op, rs );
}
}
return SLAP_CB_CONTINUE;
}
if ( op->o_tag == LDAP_REQ_SEARCH
&& op->ors_scope != LDAP_SCOPE_BASE
&& op->o_req_ndn.bv_len == rd->rd_npdn.bv_len )
{
return retcode_send_onelevel( op, rs );
}
dnParent( &op->o_req_ndn, &npdn );
if ( npdn.bv_len != rd->rd_npdn.bv_len ) {
rs->sr_err = LDAP_NO_SUCH_OBJECT;
rs->sr_matched = rd->rd_pdn.bv_val;
send_ldap_result( op, rs );
rs->sr_matched = NULL;
return rs->sr_err;
}
dnRdn( &op->o_req_ndn, &nrdn );
for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) {
struct berval rdi_nrdn;
dnRdn( &rdi->rdi_ndn, &rdi_nrdn );
if ( dn_match( &nrdn, &rdi_nrdn ) ) {
break;
}
}
if ( rdi != NULL && rdi->rdi_mask != SN_DG_OP_ALL ) {
retcode_op_e o_tag = SN_DG_OP_NONE;
switch ( op->o_tag ) {
case LDAP_REQ_ADD:
o_tag = SN_DG_OP_ADD;
break;
case LDAP_REQ_BIND:
o_tag = SN_DG_OP_BIND;
break;
case LDAP_REQ_COMPARE:
o_tag = SN_DG_OP_COMPARE;
break;
//.........这里部分代码省略.........
开发者ID:verter2015,项目名称:ReOpenLDAP,代码行数:101,代码来源:retcode.c
示例12: ndb_tool_next_id
static int ndb_tool_next_id(
Operation *op,
NdbArgs *NA,
struct berval *text,
int hole )
{
struct berval ndn = NA->e->e_nname;
int rc;
if (ndn.bv_len == 0) {
NA->e->e_id = 0;
return 0;
}
rc = ndb_entry_get_info( op, NA, 0, NULL );
if ( rc ) {
Attribute *a, tmp = {0};
if ( !be_issuffix( op->o_bd, &ndn ) ) {
struct dn_id *dptr;
struct berval npdn;
dnParent( &ndn, &npdn );
NA->e->e_nname = npdn;
NA->rdns->nr_num--;
rc = ndb_tool_next_id( op, NA, text, 1 );
NA->e->e_nname = ndn;
NA->rdns->nr_num++;
if ( rc ) {
return rc;
}
/* If parent didn't exist, it was created just now
* and its ID is now in e->e_id.
*/
dptr = (struct dn_id *)ch_malloc( sizeof( struct dn_id ) + npdn.bv_len + 1);
dptr->id = NA->e->e_id;
dptr->dn.bv_val = (char *)(dptr+1);
strcpy(dptr->dn.bv_val, npdn.bv_val );
dptr->dn.bv_len = npdn.bv_len;
if ( avl_insert( &myParents, dptr, ndb_dnid_cmp, avl_dup_error )) {
ch_free( dptr );
}
}
rc = ndb_next_id( op->o_bd, myNdb, &NA->e->e_id );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"next_id failed: %s (%d)",
myNdb->getNdbError().message, myNdb->getNdbError().code );
Debug( LDAP_DEBUG_ANY,
"=> ndb_tool_next_id: %s\n", text->bv_val, 0, 0 );
return rc;
}
if ( hole ) {
a = NA->e->e_attrs;
NA->e->e_attrs = &tmp;
tmp.a_desc = slap_schema.si_ad_objectClass;
tmp.a_vals = glueval;
tmp.a_nvals = tmp.a_vals;
tmp.a_numvals = 1;
}
rc = ndb_entry_put_info( op->o_bd, NA, 0 );
if ( hole ) {
NA->e->e_attrs = a;
}
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"ndb_entry_put_info failed: %s (%d)",
myNdb->getNdbError().message, myNdb->getNdbError().code );
Debug( LDAP_DEBUG_ANY,
"=> ndb_tool_next_id: %s\n", text->bv_val, 0, 0 );
} else if ( hole ) {
if ( nholes == nhmax - 1 ) {
if ( holes == hbuf ) {
holes = (dn_id *)ch_malloc( nhmax * sizeof(dn_id) * 2 );
AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
} else {
holes = (dn_id *)ch_realloc( holes, nhmax * sizeof(dn_id) * 2 );
}
nhmax *= 2;
}
ber_dupbv( &holes[nholes].dn, &ndn );
holes[nholes++].id = NA->e->e_id;
}
} else if ( !hole ) {
unsigned i;
for ( i=0; i<nholes; i++) {
if ( holes[i].id == NA->e->e_id ) {
int j;
free(holes[i].dn.bv_val);
for (j=i;j<nholes;j++) holes[j] = holes[j+1];
holes[j].id = 0;
nholes--;
rc = ndb_entry_put_info( op->o_bd, NA, 1 );
break;
} else if ( holes[i].id > NA->e->e_id ) {
break;
}
}
}
return rc;
}
开发者ID:bhanug,项目名称:likewise-open,代码行数:100,代码来源:tools.cpp
示例13: ndb_tool_entry_put
ID ndb_tool_entry_put(
BackendDB *be,
Entry *e,
struct berval *text )
{
struct ndb_info *ni = (struct ndb_info *) be->be_private;
struct dn_id dtmp, *dptr;
NdbArgs NA;
NdbRdns rdns;
int rc, slow = 0;
Operation op = {0};
Opheader ohdr = {0};
assert( be != NULL );
assert( slapMode & SLAP_TOOL_MODE );
assert( text != NULL );
assert( text->bv_val != NULL );
assert( text->bv_val[0] == '\0' ); /* overconservative? */
Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(ndb_tool_entry_put)
"( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 );
if ( !be_issuffix( be, &e->e_nname )) {
dnParent( &e->e_nname, &dtmp.dn );
dptr = (struct dn_id *)avl_find( myParents, &dtmp, ndb_dnid_cmp );
if ( !dptr )
slow = 1;
}
rdns.nr_num = 0;
op.o_hdr = &ohdr;
op.o_bd = be;
op.o_tmpmemctx = NULL;
op.o_tmpmfuncs = &ch_mfuncs;
if ( !slow ) {
rc = ndb_next_id( be, myNdb, &e->e_id );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"next_id failed: %s (%d)",
myNdb->getNdbError().message, myNdb->getNdbError().code );
Debug( LDAP_DEBUG_ANY,
"=> ndb_tool_next_id: %s\n", text->bv_val, 0, 0 );
return rc;
}
}
if ( !myPutTxn )
myPutTxn = myNdb->startTransaction();
if ( !myPutTxn ) {
snprintf( text->bv_val, text->bv_len,
"start_transaction failed: %s (%d)",
myNdb->getNdbError().message, myNdb->getNdbError().code );
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(ndb_tool_entry_put) ": %s\n",
text->bv_val, 0, 0 );
return NOID;
}
/* add dn2id indices */
ndb_dn2rdns( &e->e_name, &rdns );
NA.rdns = &rdns;
NA.e = e;
NA.ndb = myNdb;
NA.txn = myPutTxn;
if ( slow ) {
rc = ndb_tool_next_id( &op, &NA, text, 0 );
if( rc != 0 ) {
goto done;
}
} else {
rc = ndb_entry_put_info( be, &NA, 0 );
if ( rc != 0 ) {
goto done;
}
}
/* id2entry index */
rc = ndb_entry_put_data( be, &NA );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"ndb_entry_put_data failed: %s (%d)",
myNdb->getNdbError().message, myNdb->getNdbError().code );
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(ndb_tool_entry_put) ": %s\n",
text->bv_val, 0, 0 );
goto done;
}
done:
if( rc == 0 ) {
myPutCnt++;
if ( !( myPutCnt & 0x0f )) {
rc = myPutTxn->execute(NdbTransaction::Commit);
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"txn_commit failed: %s (%d)",
myPutTxn->getNdbError().message, myPutTxn->getNdbError().code );
//.........这里部分代码省略.........
开发者ID:bhanug,项目名称:likewise-open,代码行数:101,代码来源:tools.cpp
示例14: backsql_delete
//.........这里部分代码省略.........
}
#endif /* SLAP_CONTROL_X_TREE_DELETE */
Debug( LDAP_DEBUG_TRACE, " backsql_delete(): "
"entry \"%s\" has children\n",
op->o_req_dn.bv_val, 0, 0 );
rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
rs->sr_text = "subordinate objects must be deleted first";
/* fallthru */
default:
e = &d;
goto done;
}
assert( bsi.bsi_base_id.eid_oc != NULL );
oc = bsi.bsi_base_id.eid_oc;
if ( oc->bom_delete_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE, " backsql_delete(): "
"delete procedure is not defined "
"for this objectclass - aborting\n", 0, 0, 0 );
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
rs->sr_text = "operation not permitted within namingContext";
e = NULL;
goto done;
}
/*
* Get the parent
*/
e_id = bsi.bsi_base_id;
memset( &bsi.bsi_base_id, 0, sizeof( bsi.bsi_base_id ) );
if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
dnParent( &op->o_req_ndn, &pdn );
bsi.bsi_e = &p;
rs->sr_err = backsql_init_search( &bsi, &pdn,
LDAP_SCOPE_BASE,
(time_t)(-1), NULL, dbh, op, rs,
slap_anlist_no_attrs,
BACKSQL_ISF_GET_ENTRY );
if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
"could not retrieve deleteDN ID "
"- no such entry\n",
0, 0, 0 );
e = &p;
goto done;
}
(void)backsql_free_entryID( &bsi.bsi_base_id, 0, op->o_tmpmemctx );
/* check parent for "children" acl */
if ( !access_allowed( op, &p, slap_schema.si_ad_children,
NULL, ACL_WDEL, NULL ) )
{
Debug( LDAP_DEBUG_TRACE, " backsql_delete(): "
"no write access to parent\n",
0, 0, 0 );
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
e = &p;
goto done;
}
}
e = &d;
开发者ID:cptaffe,项目名称:openldap,代码行数:67,代码来源:delete.c
示例15: set_parents
static BerVarray
set_parents( SetCookie *cp, BerVarray set )
{
int i, j, last;
struct berval bv, pbv;
BerVarray nset, vals;
if ( set == NULL ) {
set = cp->set_op->o_tmpcalloc( 1, sizeof( struct berval ),
cp->set_op->o_tmpmemctx );
if ( set != NULL ) {
BER_BVZERO( &set[ 0 ] );
}
return set;
}
if ( BER_BVISNULL( &set[ 0 ] ) ) {
return set;
}
nset = cp->set_op->o_tmpcalloc( 1, sizeof( struct berval ), cp->set_op->o_tmpmemctx );
if ( nset == NULL ) {
ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
return NULL;
}
BER_BVZERO( &nset[ 0 ] );
for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ ) {
int level = 1;
pbv = bv = set[ i ];
for ( ; !BER_BVISEMPTY( &pbv ); dnParent( &bv, &pbv ) ) {
level++;
bv = pbv;
}
vals = cp->set_op->o_tmpcalloc( level + 1, sizeof( struct berval ), cp->set_op->o_tmpmemctx );
if ( vals == NULL ) {
ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
ber_bvarray_free_x( nset, cp->set_op->o_tmpmemctx );
return NULL;
}
BER_BVZERO( &vals[ 0 ] );
last = 0;
bv = set[ i ];
for ( j = 0 ; j < level ; j++ ) {
ber_dupbv_x( &vals[ last ], &bv, cp->set_op->o_tmpmemctx );
last++;
dnParent( &bv, &bv );
}
BER_BVZERO( &vals[ last ] );
nset = slap_set_join( cp, nset, '|', vals );
}
ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
return nset;
}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:61,代码来源:sets.c
示例16: wt_tool_next_id
static int wt_tool_next_id(
Operation *op,
Entry *e,
struct berval *text,
int hole )
{
struct wt_info *wi = (struct wt_info *) op->o_bd->be_private;
struct berval dn = e->e_name;
struct berval ndn = e->e_nname;
struct berval pdn, npdn;
int rc;
ID id = 0;
ID pid = 0;
if(ndn.bv_len == 0){
e->e_id = 0;
return 0;
}
rc = wt_dn2id(op, wc->session, &ndn, &id);
if(rc == 0){
e->e_id = id;
}else if( rc == WT_NOTFOUND ){
if ( !be_issuffix( op->o_bd, &ndn ) ) {
ID eid = e->e_id;
dnParent( &dn, &pdn );
dnParent( &ndn, &npdn );
e->e_name = pdn;
e->e_nname = npdn;
rc = wt_tool_next_id( op, e, text, 1 );
e->e_name = dn;
e->e_nname = ndn;
if ( rc ) {
return rc;
}
/* If parent didn't exist, it was created just now
* and its ID is now in e->e_id. Make sure the current
* entry gets added under the new parent ID.
*/
if ( eid != e->e_id ) {
pid = e->e_id;
}
}else{
pid = id;
}
wt_next_id( op->o_bd, &e->e_id );
rc = wt_dn2id_add(op, wc->session, pid, e);
if( rc ){
snprintf( text->bv_val, text->bv_len,
"wt_dn2id_add failed: %s (%d)",
wiredtiger_strerror(rc), rc );
Debug( LDAP_DEBUG_ANY,
"=> wt_tool_next_id: %s\n", text->bv_val, 0, 0 );
}
}else if ( !hole ) {
unsigned i, j;
e->e_id = id;
for ( i=0; i<nholes; i++) {
if ( holes[i].id == e->e_id ) {
free(holes[i].dn.bv_val);
for (j=i;j<nholes;j++) holes[j] = holes[j+1];
holes[j].id = 0;
nholes--;
break;
} else if ( holes[i].id > e->e_id ) {
break;
}
}
}
return rc;
}
开发者ID:Distrotech,项目名称:openldap,代码行数:73,代码来源:tools.c
示例17: bdb_tool_next_id
static int bdb_tool_next_id(
Operation *op,
DB_TXN *tid,
Entry *e,
struct berval *text,
int hole )
{
struct berval dn = e->e_name;
struct berval ndn = e->e_nname;
struct berval pdn, npdn;
EntryInfo *ei = NULL, eidummy;
int rc;
if (ndn.bv_len == 0) {
e->e_id = 0;
return 0;
}
rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
if ( ei ) bdb_cache_entryinfo_unlock( ei );
if ( rc == DB_NOTFOUND ) {
if ( !be_issuffix( op->o_bd, &ndn ) ) {
ID eid = e->e_id;
dnParent( &dn, &pdn );
dnParent( &ndn, &npdn );
e->e_name = pdn;
e->e_nname = npdn;
rc = bdb_tool_next_id( op, tid, e, text, 1 );
e->e_name = dn;
e->e_nname = ndn;
if ( rc ) {
return rc;
}
/* If parent didn't exist, it was created just now
* and its ID is now in e->e_id. Make sure the current
* entry gets added under the new parent ID.
*/
if ( eid != e->e_id ) {
eidummy.bei_id = e->e_id;
ei = &eidummy;
}
}
rc = bdb_next_id( op->o_bd, &e->e_id );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"next_id failed: %s (%d)",
db_strerror(rc), rc );
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
return rc;
}
rc = bdb_dn2id_add( op, tid, ei, e );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"dn2id_add failed: %s (%d)",
db_strerror(rc), rc );
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
} else if ( hole ) {
if ( nholes == nhmax - 1 ) {
if ( holes == hbuf ) {
holes = ch_malloc( nhmax * sizeof(dn_id) * 2 );
AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
} else {
holes = ch_realloc( holes, nhmax * sizeof(dn_id) * 2 );
}
nhmax *= 2;
}
ber_dupbv( &holes[nholes].dn, &ndn );
holes[nholes++].id = e->e_id;
}
} else if ( !hole ) {
unsigned i, j;
e->e_id = ei->bei_id;
for ( i=0; i<nholes; i++) {
if ( holes[i].id == e->e_id ) {
free(holes[i].dn.bv_val);
for (j=i;j<nholes;j++) holes[j] = holes[j+1];
holes[j].id = 0;
nholes--;
break;
} else if ( holes[i].id > e->e_id ) {
break;
}
}
}
return rc;
}
开发者ID:rouzier,项目名称:openldap,代码行数:90,代码来源:tools.c
示例18: bdb_delete
//.........这里部分代码省略.........
rs->sr_err = LDAP_OTHER;
rs->sr_text = "internal error";
goto return_results;
}
if ( op->o_abandon ) {
rs->sr_err = SLAPD_ABANDON;
goto return_results;
}
parent_is_glue = 0;
parent_is_leaf = 0;
bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
rs->sr_text = NULL;
if( rs->sr_err != 0 ) {
Debug( LDAP_DEBUG_TRACE,
LDAP_XSTRING(bdb_delete) ": txn_begin failed: "
"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "internal error";
goto return_results;
}
opinfo.boi_oe.oe_key = bdb;
opinfo.boi_txn = ltid;
opinfo.boi_err = 0;
opinfo.boi_acl_cache = op->o_do_not_cache;
LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
dnParent( &op->o_req_ndn, &pdn );
}
/* get entry */
rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
&lock );
switch( rs->sr_err ) {
case 0:
case DB_NOTFOUND:
break;
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto retry;
case LDAP_BUSY:
rs->sr_text = "ldap server busy";
goto return_results;
default:
rs->sr_err = LDAP_OTHER;
rs->sr_text = "internal error";
goto return_results;
}
if ( rs->sr_err == 0 ) {
e = ei->bei_e;
eip = ei->bei_parent;
} else {
matched = ei->bei_e;
}
/* FIXME : dn2entry() should return non-glue entry */
if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
Debug( LDAP_DEBUG_ARGS,
开发者ID:Joywar,项目名称:openldap,代码行数:67,代码来源:delete.c
示例19: aci_mask
//.........这里部分代码省略.........
}
/* NOTE: this may fail if a DN contains a valid '#' (unescaped);
* just grab all the berval up to its end (ITS#3303).
* NOTE: the problem could be solved by providing the DN with
* the embedded '#' encoded as hexpairs: "cn=Foo#Bar" would
* become "cn=Foo\23Bar" and be safely used by aci_mask(). */
#if 0
if ( acl_get_part( aci, 4, '#', &sdn ) < 0 ) {
return 0;
}
#endif
sdn.bv_val = type.bv_val + type.bv_len + STRLENOF( "#" );
sdn.bv_len = aci->bv_len - ( sdn.bv_val - aci->bv_val );
/* get the type options, if any */
if ( acl_get_part( &type, 1, '/', &opts ) > 0 ) {
opts.bv_len = type.bv_len - ( opts.bv_val - type.bv_val );
type.bv_len = opts.bv_val - type.bv_val - 1;
} else {
BER_BVZERO( &opts );
}
if ( ber_bvcmp( &aci_bv[ ACI_BV_ACCESS_ID ], &type ) == 0 ) {
return dn_match( &op->o_ndn, &sdn );
} else if ( ber_bvcmp( &aci_bv[ ACI_BV_SUBTREE ], &type ) == 0 ) {
return dnIsSuffix( &op->o_ndn, &sdn );
} else if ( ber_bvcmp( &aci_bv[ ACI_BV_ONELEVEL ], &type ) == 0 ) {
struct berval pdn;
dnParent( &sdn, &pdn );
return dn_match( &op->o_ndn, &pdn );
} else if ( ber_bvcmp( &aci_bv[ ACI_BV_CHILDREN ], &type ) == 0 ) {
return ( !dn_match( &op->o_ndn, &sdn ) && dnIsSuffix( &op->o_ndn, &sdn ) );
} else if ( ber_bvcmp( &aci_bv[ ACI_BV_SELF ], &type ) == 0 ) {
return dn_match( &op->o_ndn, &e->e_nname );
} else if ( ber_bvcmp( &aci_bv[ ACI_BV_DNATTR ], &type ) == 0 ) {
Attribute *at;
AttributeDescription *ad = NULL;
const char *text;
rc = slap_bv2ad( &sdn, &ad, &text );
assert( rc == LDAP_SUCCESS );
rc = 0;
for ( at = attrs_find( e->e_attrs, ad );
at != NULL;
at = attrs_find( at->a_next, ad ) )
{
if ( attr_valfind( at,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
&op->o_ndn, NULL, op->o_tmpmemctx ) == 0 )
{
rc = 1;
break;
}
}
开发者ID:Smilefant,项目名称:ReOpenLDAP,代码行数:66,代码来源:aci.c
示例20: bdb_modrdn
//.........这里部分代码省略.........
goto return_results;
}
ei->bei_state |= CACHE_ENTRY_NO_KIDS;
#endif
if (!manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
rs->sr_ref = get_entry_referrals( op, e );
Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn)
": entry %s is referral\n", e->e_dn, 0, 0 );
rs->sr_err = LDAP_REFERRAL,
rs->sr_matched = e->e_name.bv_val;
send_ldap_result( op, rs );
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
rs->sr_matched = NULL;
goto done;
}
if ( be_issuffix( op->o_bd, &e->e_nname ) ) {
#ifdef BDB_MULTIPLE_SUFFIXES
/* Allow renaming one suffix entry to another */
p_ndn = slap_empty_bv;
#else
/* There can only be one suffix entry */
rs->sr_err = LDAP_NAMING_VIOLATION;
rs->sr_text = "cannot rename suffix entry";
goto return_results;
#endif
} else {
dnParent( &e->e_nname, &p_ndn );
}
np_ndn = &p_ndn;
eip = ei->bei_parent;
if ( eip && eip->bei_id ) {
/* Make sure parent entry exist and we can write its
* children.
*/
rs->sr_err = bdb_cache_find_id( op, ltid,
eip->bei_id, &eip, 0, &plock );
switch( rs->sr_err ) {
case 0:
case DB_NOTFOUND:
break;
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto retry;
case LDAP_BUSY:
rs->sr_text = "ldap server busy";
goto return_results;
default:
rs->sr_err = LDAP_OTHER;
rs->sr_text = "internal error";
goto return_results;
}
p = eip->bei_e;
if( p == NULL) {
Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn)
": parent does not exist\n", 0, 0, 0);
rs->sr_err = LDAP_OTHER;
rs->sr_text = "old entry's parent does not exist";
开发者ID:DanahBlanahaseth,项目名称:cniiag_ldap,代码行数:67,代码来源:modrdn.c
注:本文中的dnParent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论