]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/ppolicy.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap / ppolicy.c
index 2551fb5876e1a81d027f1f579285ed0b2bc7b0d7..05f1873b277e150ec90aac38a154e933f0a74d81 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2006 The OpenLDAP Foundation.
+ * Copyright 2004-2014 The OpenLDAP Foundation.
  * Portions Copyright 2004 Hewlett-Packard Company.
  * Portions Copyright 2004 Howard Chu, Symas Corp.
  * All rights reserved.
@@ -61,22 +61,14 @@ int
 ldap_create_passwordpolicy_control( LDAP *ld,
                                     LDAPControl **ctrlp )
 {
-       BerElement *ber;
-
        assert( ld != NULL );
        assert( LDAP_VALID( ld ) );
        assert( ctrlp != NULL );
 
-       if ((ber = ldap_alloc_ber_with_options(ld)) == NULL) {
-               ld->ld_errno = LDAP_NO_MEMORY;
-               return(LDAP_NO_MEMORY);
-       }
+       ld->ld_errno = ldap_control_create( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
+               0, NULL, 0, ctrlp );
 
-       ld->ld_errno = ldap_create_control( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
-               ber, 0, ctrlp);
-
-       ber_free(ber, 1);
-       return(ld->ld_errno);
+       return ld->ld_errno;
 }
 
 
@@ -88,8 +80,9 @@ ldap_create_passwordpolicy_control( LDAP *ld,
    ld           (IN)   An LDAP session handle.
    
    ctrl         (IN)   The address of an
-                                          LDAPControl structure, typically obtained 
-                                          by a call to ldap_find_control().
+                                          LDAPControl structure, either obtained 
+                                          by running thorugh the list of response controls or
+                                          by a call to ldap_control_find().
 
    exptimep     (OUT)  This result parameter is filled in with the number of seconds before
                                            the password will expire, if expiration is imminent
@@ -141,6 +134,11 @@ ldap_parse_passwordpolicy_control(
        assert( LDAP_VALID( ld ) );
        assert( ctrl != NULL );
 
+       if ( !ctrl->ldctl_value.bv_val ) {
+               ld->ld_errno = LDAP_DECODING_ERROR;
+               return(ld->ld_errno);
+       }
+
        /* Create a BerElement from the berval returned in the control. */
        ber = ber_init(&ctrl->ldctl_value);