2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2013 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
19 #include <ac/stdlib.h>
20 #include <ac/string.h>
26 ldap_create_assertion_control_value(
29 struct berval *value )
31 BerElement *ber = NULL;
34 if ( assertion == NULL || assertion[ 0 ] == '\0' ) {
35 ld->ld_errno = LDAP_PARAM_ERROR;
39 if ( value == NULL ) {
40 ld->ld_errno = LDAP_PARAM_ERROR;
46 ber = ldap_alloc_ber_with_options( ld );
48 ld->ld_errno = LDAP_NO_MEMORY;
52 err = ldap_pvt_put_filter( ber, assertion );
54 ld->ld_errno = LDAP_ENCODING_ERROR;
58 err = ber_flatten2( ber, value, 1 );
60 ld->ld_errno = LDAP_NO_MEMORY;
73 ldap_create_assertion_control(
81 if ( ctrlp == NULL ) {
82 ld->ld_errno = LDAP_PARAM_ERROR;
86 ld->ld_errno = ldap_create_assertion_control_value( ld,
88 if ( ld->ld_errno == LDAP_SUCCESS ) {
89 ld->ld_errno = ldap_control_create( LDAP_CONTROL_ASSERT,
90 iscritical, &value, 0, ctrlp );
91 if ( ld->ld_errno != LDAP_SUCCESS ) {
92 LDAP_FREE( value.bv_val );