]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/stctrl.c
ITS#6254
[openldap] / libraries / libldap / stctrl.c
index bfec5c44e734309d7b6eaa1da486ed7858a6aa07..4ba0c2197a0effa469f499b23e03f3812b28098d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * Portions Copyright 2007 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -60,6 +60,7 @@ param_error:;
        }
 
        assert( LDAP_VALID( ld ) );
+       ld->ld_errno = LDAP_SUCCESS;
 
        /* check sizes according to I.D. */
        if ( sessionSourceIp == NULL ) {
@@ -137,7 +138,6 @@ ldap_create_session_tracking_control(
        LDAPControl     **ctrlp )
 {
        struct berval   value;
-       BerElement      *ber;
 
        if ( ctrlp == NULL ) {
                ld->ld_errno = LDAP_PARAM_ERROR;
@@ -148,12 +148,9 @@ ldap_create_session_tracking_control(
                sessionSourceIp, sessionSourceName, formatOID,
                sessionTrackingIdentifier, &value );
        if ( ld->ld_errno == LDAP_SUCCESS ) {
-               ld->ld_errno = ldap_create_control( LDAP_CONTROL_X_SESSION_TRACKING,
-                       NULL, 0, ctrlp );
-               if ( ld->ld_errno == LDAP_SUCCESS ) {
-                       (*ctrlp)->ldctl_value = value;
-
-               } else {
+               ld->ld_errno = ldap_control_create( LDAP_CONTROL_X_SESSION_TRACKING,
+                       0, &value, 0, ctrlp );
+               if ( ld->ld_errno != LDAP_SUCCESS ) {
                        LDAP_FREE( value.bv_val );
                }
        }