]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/ppolicy.c
ITS#6437 cleanup (noop change): Compute pad,order_start at compile time
[openldap] / libraries / libldap / ppolicy.c
index c4f035565168831db939f1cd1388dcc2105f847b..65ea0f0635e771adfe4b3e6d0761ec1ed7711bdd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2006 The OpenLDAP Foundation.
+ * Copyright 2004-2011 The OpenLDAP Foundation.
  * Portions Copyright 2004 Hewlett-Packard Company.
  * Portions Copyright 2004 Howard Chu, Symas Corp.
  * All rights reserved.
  * Portions Copyright 2004 Hewlett-Packard Company.
  * Portions Copyright 2004 Howard Chu, Symas Corp.
  * All rights reserved.
 
 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
 
 
 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
 
-#define PPOLICY_WARNING 0xa0L
-#define PPOLICY_ERROR 0xa1L
+/* IMPLICIT TAGS, all context-specific */
+#define PPOLICY_WARNING 0xa0L  /* constructed + 0 */
+#define PPOLICY_ERROR 0x81L            /* primitive + 1 */
 
 
-#define PPOLICY_EXPIRE 0xa0L
-#define PPOLICY_GRACE  0xa1L
+#define PPOLICY_EXPIRE 0x80L   /* primitive + 0 */
+#define PPOLICY_GRACE  0x81L   /* primitive + 1 */
 
 /*---
    ldap_create_passwordpolicy_control
 
 /*---
    ldap_create_passwordpolicy_control
@@ -60,22 +61,14 @@ int
 ldap_create_passwordpolicy_control( LDAP *ld,
                                     LDAPControl **ctrlp )
 {
 ldap_create_passwordpolicy_control( LDAP *ld,
                                     LDAPControl **ctrlp )
 {
-       BerElement *ber;
-
        assert( ld != NULL );
        assert( LDAP_VALID( ld ) );
        assert( ctrlp != NULL );
 
        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_create_control( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
-               ber, 0, ctrlp);
+       ld->ld_errno = ldap_control_create( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
+               0, NULL, 0, ctrlp );
 
 
-       ber_free(ber, 1);
-       return(ld->ld_errno);
+       return ld->ld_errno;
 }
 
 
 }
 
 
@@ -86,9 +79,10 @@ ldap_create_passwordpolicy_control( LDAP *ld,
 
    ld           (IN)   An LDAP session handle.
    
 
    ld           (IN)   An LDAP session handle.
    
-   ctrls        (IN)   The address of an
-                                          LDAPControl structure, typically obtained 
-                                          by a call to ldap_find_control().
+   ctrl         (IN)   The address of an
+                                          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
 
    exptimep     (OUT)  This result parameter is filled in with the number of seconds before
                                            the password will expire, if expiration is imminent
@@ -125,8 +119,8 @@ int
 ldap_parse_passwordpolicy_control(
        LDAP           *ld,
        LDAPControl    *ctrl,
 ldap_parse_passwordpolicy_control(
        LDAP           *ld,
        LDAPControl    *ctrl,
-       int            *expirep,
-       int            *gracep,
+       ber_int_t      *expirep,
+       ber_int_t      *gracep,
        LDAPPasswordPolicyError *errorp )
 {
        BerElement  *ber;
        LDAPPasswordPolicyError *errorp )
 {
        BerElement  *ber;