int LDAP_CALL ldap_create_userstatus_control ( LDAP *ld, const char ctl_iscritical, LDAPControl **ctrlp ) { int rc; if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { return( LDAP_PARAM_ERROR ); } if ( ctrlp == NULL ) { LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); return ( LDAP_PARAM_ERROR ); } rc = nsldapi_build_control( LDAP_CONTROL_ACCOUNT_USABLE, NULL, 0, ctl_iscritical, ctrlp ); LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); return( rc ); }
int LDAP_CALL ldap_create_proxyauth_control ( LDAP *ld, const char *dn, const char ctl_iscritical, LDAPControl **ctrlp ) { BerElement *ber; int rc; if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { return( LDAP_PARAM_ERROR ); } if ( ctrlp == NULL ) { LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); return ( LDAP_PARAM_ERROR ); } if (NULL == dn) { dn = ""; } /* create a ber package to hold the controlValue */ if ( ( nsldapi_alloc_ber_with_options( ld, &ber ) ) != LDAP_SUCCESS ) { LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); return( LDAP_NO_MEMORY ); } if ( LBER_ERROR == ber_printf( ber, "{s}", dn ) ) { LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL ); ber_free( ber, 1 ); return( LDAP_ENCODING_ERROR ); } rc = nsldapi_build_control( LDAP_CONTROL_PROXYAUTH, ber, 1, ctl_iscritical, ctrlp ); LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); return( rc ); }
int LDAP_CALL ldap_create_geteffectiveRights_control ( LDAP *ld, const char *authzid, const char **attrlist, const char ctl_iscritical, LDAPControl **ctrlp ) { BerElement *ber; int rc; if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { return( LDAP_PARAM_ERROR ); } if ( ctrlp == NULL ) { LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); return ( LDAP_PARAM_ERROR ); } if (NULL == authzid) { authzid = ""; } /* create a ber package to hold the controlValue */ if ( ( nsldapi_alloc_ber_with_options( ld, &ber ) ) != LDAP_SUCCESS ) { LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); return( LDAP_NO_MEMORY ); } if ( LBER_ERROR == ber_printf( ber, "{s{v}}", authzid, attrlist ) ) { LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL ); ber_free( ber, 1 ); return( LDAP_ENCODING_ERROR ); } rc = nsldapi_build_control( LDAP_CONTROL_GETEFFECTIVERIGHTS_REQUEST, ber, 1, ctl_iscritical, ctrlp ); LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); return( rc ); }
int LDAP_CALL ldap_create_sort_control ( LDAP *ld, LDAPsortkey **sortKeyList, const char ctl_iscritical, LDAPControl **ctrlp ) { BerElement *ber; int i, rc; if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { return( LDAP_PARAM_ERROR ); } if ( sortKeyList == NULL || ctrlp == NULL ) { LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); return ( LDAP_PARAM_ERROR ); } /* create a ber package to hold the controlValue */ if ( ( nsldapi_alloc_ber_with_options( ld, &ber ) ) != LDAP_SUCCESS ) { LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); return( LDAP_NO_MEMORY ); } /* encode the start of the sequence of sequences into the ber */ if ( ber_printf( ber, "{" ) == -1 ) { goto encoding_error_exit; } /* the sort control value will be encoded as a sequence of sequences which are each encoded as one of the following: {s} or {sts} or {stb} or {ststb} since the orderingRule and reverseOrder flag are both optional */ for ( i = 0; sortKeyList[i] != NULL; i++ ) { /* encode the attributeType into the ber */ if ( ber_printf( ber, "{s", (sortKeyList[i])->sk_attrtype ) == -1 ) { goto encoding_error_exit; } /* encode the optional orderingRule into the ber */ if ( (sortKeyList[i])->sk_matchruleoid != NULL ) { if ( ber_printf( ber, "ts", LDAP_TAG_SK_MATCHRULE, (sortKeyList[i])->sk_matchruleoid ) == -1 ) { goto encoding_error_exit; } } /* Encode the optional reverseOrder flag into the ber. */ /* If the flag is false, it should be absent. */ if ( (sortKeyList[i])->sk_reverseorder ) { if ( ber_printf( ber, "tb}", LDAP_TAG_SK_REVERSE, (sortKeyList[i])->sk_reverseorder ) == -1 ) { goto encoding_error_exit; } } else { if ( ber_printf( ber, "}" ) == -1 ) { goto encoding_error_exit; } } } /* encode the end of the sequence of sequences into the ber */ if ( ber_printf( ber, "}" ) == -1 ) { goto encoding_error_exit; } rc = nsldapi_build_control( LDAP_CONTROL_SORTREQUEST, ber, 1, ctl_iscritical, ctrlp ); LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); return( rc ); encoding_error_exit: LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL ); ber_free( ber, 1 ); return( LDAP_ENCODING_ERROR ); }