1 #pragma ident "%Z%%M% %I% %E% SMI"
4 * The contents of this file are subject to the Netscape Public
5 * License Version 1.1 (the "License"); you may not use this file
6 * except in compliance with the License. You may obtain a copy of
7 * the License at http://www.mozilla.org/NPL/
9 * Software distributed under the License is distributed on an "AS
10 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 * implied. See the License for the specific language governing
12 * rights and limitations under the License.
14 * The Original Code is Mozilla Communicator client code, released
17 * The Initial Developer of the Original Code is Netscape
18 * Communications Corporation. Portions created by Netscape are
19 * Copyright (C) 1998-1999 Netscape Communications Corporation. All
26 /* ldap_create_proxyauth_control
28 Create a "version 1" proxied authorization control.
32 ld LDAP pointer to the desired connection
34 dn The dn used in the proxy auth
36 ctl_iscritical Indicates whether the control is critical of not. If
37 this field is non-zero, the operation will only be car-
38 ried out if the control is recognized by the server
41 ctrlp the address of a place to put the constructed control
46 ldap_create_proxyauth_control (
49 const char ctl_iscritical
,
56 if ( !NSLDAPI_VALID_LDAP_POINTER( ld
)) {
57 return( LDAP_PARAM_ERROR
);
60 if ( ctrlp
== NULL
) {
61 LDAP_SET_LDERRNO( ld
, LDAP_PARAM_ERROR
, NULL
, NULL
);
62 return ( LDAP_PARAM_ERROR
);
69 /* create a ber package to hold the controlValue */
70 if ( ( nsldapi_alloc_ber_with_options( ld
, &ber
) ) != LDAP_SUCCESS
) {
71 LDAP_SET_LDERRNO( ld
, LDAP_NO_MEMORY
, NULL
, NULL
);
72 return( LDAP_NO_MEMORY
);
77 if ( LBER_ERROR
== ber_printf( ber
,
81 LDAP_SET_LDERRNO( ld
, LDAP_ENCODING_ERROR
, NULL
, NULL
);
83 return( LDAP_ENCODING_ERROR
);
86 rc
= nsldapi_build_control( LDAP_CONTROL_PROXYAUTH
, ber
, 1,
87 ctl_iscritical
, ctrlp
);
89 LDAP_SET_LDERRNO( ld
, rc
, NULL
, NULL
);
95 /* ldap_create_proxiedauth_control
97 Create a "version 2" proxied authorization control.
101 ld LDAP pointer to the desired connection
103 authzid The authorization identity used in the proxy auth,
104 e.g., dn:uid=bjensen,dc=example,dc=com
106 ctrlp the address of a place to put the constructed control
111 ldap_create_proxiedauth_control (
120 if ( !NSLDAPI_VALID_LDAP_POINTER( ld
)) {
121 return( LDAP_PARAM_ERROR
);
124 if ( ctrlp
== NULL
|| authzid
== NULL
) {
125 LDAP_SET_LDERRNO( ld
, LDAP_PARAM_ERROR
, NULL
, NULL
);
126 return ( LDAP_PARAM_ERROR
);
129 /* create a ber package to hold the controlValue */
130 if ( ( nsldapi_alloc_ber_with_options( ld
, &ber
) ) != LDAP_SUCCESS
) {
131 LDAP_SET_LDERRNO( ld
, LDAP_NO_MEMORY
, NULL
, NULL
);
132 return( LDAP_NO_MEMORY
);
137 if ( LBER_ERROR
== ber_printf( ber
,
141 LDAP_SET_LDERRNO( ld
, LDAP_ENCODING_ERROR
, NULL
, NULL
);
143 return( LDAP_ENCODING_ERROR
);
146 rc
= nsldapi_build_control( LDAP_CONTROL_PROXIEDAUTH
, ber
, 1, 1, ctrlp
);
148 LDAP_SET_LDERRNO( ld
, rc
, NULL
, NULL
);