@@ -3879,195 +3879,6 @@ PHP_FUNCTION(ldap_8859_to_t61)
3879
3879
/* }}} */
3880
3880
#endif
3881
3881
3882
- #ifdef LDAP_CONTROL_PAGEDRESULTS
3883
- /* {{{ Inject paged results control*/
3884
- PHP_FUNCTION (ldap_control_paged_result )
3885
- {
3886
- zend_long pagesize ;
3887
- zend_bool iscritical ;
3888
- zval * link ;
3889
- char * cookie = NULL ;
3890
- size_t cookie_len = 0 ;
3891
- struct berval lcookie = { 0L , NULL };
3892
- ldap_linkdata * ld ;
3893
- LDAP * ldap ;
3894
- BerElement * ber = NULL ;
3895
- LDAPControl ctrl , * ctrlsp [2 ];
3896
- int rc , myargcount = ZEND_NUM_ARGS ();
3897
-
3898
- if (zend_parse_parameters (myargcount , "rl|bs" , & link , & pagesize , & iscritical , & cookie , & cookie_len ) != SUCCESS ) {
3899
- RETURN_THROWS ();
3900
- }
3901
-
3902
- if (Z_TYPE_P (link ) == IS_NULL ) {
3903
- ldap = NULL ;
3904
- } else {
3905
- if ((ld = (ldap_linkdata * )zend_fetch_resource_ex (link , "ldap link" , le_link )) == NULL ) {
3906
- RETURN_THROWS ();
3907
- }
3908
- ldap = ld -> link ;
3909
- }
3910
-
3911
- ber = ber_alloc_t (LBER_USE_DER );
3912
- if (ber == NULL ) {
3913
- php_error_docref (NULL , E_WARNING , "Unable to alloc BER encoding resources for paged results control" );
3914
- RETURN_FALSE ;
3915
- }
3916
-
3917
- ctrl .ldctl_iscritical = 0 ;
3918
-
3919
- switch (myargcount ) {
3920
- case 4 :
3921
- lcookie .bv_val = cookie ;
3922
- lcookie .bv_len = cookie_len ;
3923
- /* fallthru */
3924
- case 3 :
3925
- ctrl .ldctl_iscritical = (int )iscritical ;
3926
- /* fallthru */
3927
- }
3928
-
3929
- if (ber_printf (ber , "{iO}" , (int )pagesize , & lcookie ) == LBER_ERROR ) {
3930
- php_error_docref (NULL , E_WARNING , "Unable to BER printf paged results control" );
3931
- RETVAL_FALSE ;
3932
- goto lcpr_error_out ;
3933
- }
3934
- rc = ber_flatten2 (ber , & ctrl .ldctl_value , 0 );
3935
- if (rc == LBER_ERROR ) {
3936
- php_error_docref (NULL , E_WARNING , "Unable to BER encode paged results control" );
3937
- RETVAL_FALSE ;
3938
- goto lcpr_error_out ;
3939
- }
3940
-
3941
- ctrl .ldctl_oid = LDAP_CONTROL_PAGEDRESULTS ;
3942
-
3943
- if (ldap ) {
3944
- /* directly set the option */
3945
- ctrlsp [0 ] = & ctrl ;
3946
- ctrlsp [1 ] = NULL ;
3947
-
3948
- rc = ldap_set_option (ldap , LDAP_OPT_SERVER_CONTROLS , ctrlsp );
3949
- if (rc != LDAP_SUCCESS ) {
3950
- php_error_docref (NULL , E_WARNING , "Unable to set paged results control: %s (%d)" , ldap_err2string (rc ), rc );
3951
- RETVAL_FALSE ;
3952
- goto lcpr_error_out ;
3953
- }
3954
- RETVAL_TRUE ;
3955
- } else {
3956
- /* return a PHP control object */
3957
- array_init (return_value );
3958
-
3959
- add_assoc_string (return_value , "oid" , ctrl .ldctl_oid );
3960
- if (ctrl .ldctl_value .bv_len ) {
3961
- add_assoc_stringl (return_value , "value" , ctrl .ldctl_value .bv_val , ctrl .ldctl_value .bv_len );
3962
- }
3963
- if (ctrl .ldctl_iscritical ) {
3964
- add_assoc_bool (return_value , "iscritical" , ctrl .ldctl_iscritical );
3965
- }
3966
- }
3967
-
3968
- lcpr_error_out :
3969
- if (ber != NULL ) {
3970
- ber_free (ber , 1 );
3971
- }
3972
- return ;
3973
- }
3974
- /* }}} */
3975
-
3976
- /* {{{ Extract paged results control response */
3977
- PHP_FUNCTION (ldap_control_paged_result_response )
3978
- {
3979
- zval * link , * result , * cookie , * estimated ;
3980
- struct berval lcookie ;
3981
- int lestimated ;
3982
- ldap_linkdata * ld ;
3983
- LDAPMessage * ldap_result ;
3984
- LDAPControl * * lserverctrls , * lctrl ;
3985
- BerElement * ber ;
3986
- ber_tag_t tag ;
3987
- int rc , lerrcode , myargcount = ZEND_NUM_ARGS ();
3988
-
3989
- if (zend_parse_parameters (myargcount , "rr|zz" , & link , & result , & cookie , & estimated ) != SUCCESS ) {
3990
- RETURN_THROWS ();
3991
- }
3992
-
3993
- if ((ld = (ldap_linkdata * )zend_fetch_resource (Z_RES_P (link ), "ldap link" , le_link )) == NULL ) {
3994
- RETURN_THROWS ();
3995
- }
3996
-
3997
- if ((ldap_result = (LDAPMessage * )zend_fetch_resource (Z_RES_P (result ), "ldap result" , le_result )) == NULL ) {
3998
- RETURN_THROWS ();
3999
- }
4000
-
4001
- rc = ldap_parse_result (ld -> link ,
4002
- ldap_result ,
4003
- & lerrcode ,
4004
- NULL , /* matcheddn */
4005
- NULL , /* errmsg */
4006
- NULL , /* referrals */
4007
- & lserverctrls ,
4008
- 0 );
4009
-
4010
- if (rc != LDAP_SUCCESS ) {
4011
- php_error_docref (NULL , E_WARNING , "Unable to parse result: %s (%d)" , ldap_err2string (rc ), rc );
4012
- RETURN_FALSE ;
4013
- }
4014
-
4015
- if (lerrcode != LDAP_SUCCESS ) {
4016
- php_error_docref (NULL , E_WARNING , "Result is: %s (%d)" , ldap_err2string (lerrcode ), lerrcode );
4017
- RETURN_FALSE ;
4018
- }
4019
-
4020
- if (lserverctrls == NULL ) {
4021
- php_error_docref (NULL , E_WARNING , "No server controls in result" );
4022
- RETURN_FALSE ;
4023
- }
4024
-
4025
- lctrl = ldap_control_find (LDAP_CONTROL_PAGEDRESULTS , lserverctrls , NULL );
4026
- if (lctrl == NULL ) {
4027
- ldap_controls_free (lserverctrls );
4028
- php_error_docref (NULL , E_WARNING , "No paged results control response in result" );
4029
- RETURN_FALSE ;
4030
- }
4031
-
4032
- ber = ber_init (& lctrl -> ldctl_value );
4033
- if (ber == NULL ) {
4034
- ldap_controls_free (lserverctrls );
4035
- php_error_docref (NULL , E_WARNING , "Unable to alloc BER decoding resources for paged results control response" );
4036
- RETURN_FALSE ;
4037
- }
4038
-
4039
- tag = ber_scanf (ber , "{io}" , & lestimated , & lcookie );
4040
- (void )ber_free (ber , 1 );
4041
-
4042
- if (tag == LBER_ERROR ) {
4043
- ldap_controls_free (lserverctrls );
4044
- php_error_docref (NULL , E_WARNING , "Unable to decode paged results control response" );
4045
- RETURN_FALSE ;
4046
- }
4047
-
4048
- if (lestimated < 0 ) {
4049
- ldap_controls_free (lserverctrls );
4050
- php_error_docref (NULL , E_WARNING , "Invalid paged results control response value" );
4051
- RETURN_FALSE ;
4052
- }
4053
-
4054
- ldap_controls_free (lserverctrls );
4055
- if (myargcount == 4 ) {
4056
- ZEND_TRY_ASSIGN_REF_LONG (estimated , lestimated );
4057
- }
4058
-
4059
- if (lcookie .bv_len == 0 ) {
4060
- ZEND_TRY_ASSIGN_REF_EMPTY_STRING (cookie );
4061
- } else {
4062
- ZEND_TRY_ASSIGN_REF_STRINGL (cookie , lcookie .bv_val , lcookie .bv_len );
4063
- }
4064
- ldap_memfree (lcookie .bv_val );
4065
-
4066
- RETURN_TRUE ;
4067
- }
4068
- /* }}} */
4069
- #endif
4070
-
4071
3882
/* {{{ Extended operations, Pierangelo Masarati */
4072
3883
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
4073
3884
/* {{{ Extended operation */
0 commit comments