1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate /* 10*0Sstevel@tonic-gate * The contents of this file are subject to the Netscape Public 11*0Sstevel@tonic-gate * License Version 1.1 (the "License"); you may not use this file 12*0Sstevel@tonic-gate * except in compliance with the License. You may obtain a copy of 13*0Sstevel@tonic-gate * the License at http://www.mozilla.org/NPL/ 14*0Sstevel@tonic-gate * 15*0Sstevel@tonic-gate * Software distributed under the License is distributed on an "AS 16*0Sstevel@tonic-gate * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 17*0Sstevel@tonic-gate * implied. See the License for the specific language governing 18*0Sstevel@tonic-gate * rights and limitations under the License. 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * The Original Code is Mozilla Communicator client code, released 21*0Sstevel@tonic-gate * March 31, 1998. 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate * The Initial Developer of the Original Code is Netscape 24*0Sstevel@tonic-gate * Communications Corporation. Portions created by Netscape are 25*0Sstevel@tonic-gate * Copyright (C) 1998-1999 Netscape Communications Corporation. All 26*0Sstevel@tonic-gate * Rights Reserved. 27*0Sstevel@tonic-gate * 28*0Sstevel@tonic-gate * Contributor(s): 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate /* 32*0Sstevel@tonic-gate * Public interface for libprldap -- use NSPR (Netscape Portable Runtime) 33*0Sstevel@tonic-gate * I/O, threads, etc. with libldap. 34*0Sstevel@tonic-gate * 35*0Sstevel@tonic-gate */ 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include "ldappr-int.h" 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Function: prldap_init(). 42*0Sstevel@tonic-gate * 43*0Sstevel@tonic-gate * Create a new LDAP session handle, but with NSPR I/O, threading, and DNS 44*0Sstevel@tonic-gate * functions installed. 45*0Sstevel@tonic-gate * 46*0Sstevel@tonic-gate * Pass a non-zero value for the 'shared' parameter if you plan to use 47*0Sstevel@tonic-gate * this LDAP * handle from more than one thread. 48*0Sstevel@tonic-gate * 49*0Sstevel@tonic-gate * prldap_init() returns an LDAP session handle (or NULL if an error occurs). 50*0Sstevel@tonic-gate */ 51*0Sstevel@tonic-gate LDAP * LDAP_CALL 52*0Sstevel@tonic-gate prldap_init( const char *defhost, int defport, int shared ) 53*0Sstevel@tonic-gate { 54*0Sstevel@tonic-gate LDAP *ld; 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate if (( ld = ldap_init( defhost, defport )) != NULL ) { 57*0Sstevel@tonic-gate if ( prldap_install_routines( ld, shared ) != LDAP_SUCCESS ) { 58*0Sstevel@tonic-gate prldap_set_system_errno( EINVAL ); /* XXXmcs: just a guess! */ 59*0Sstevel@tonic-gate ldap_unbind( ld ); 60*0Sstevel@tonic-gate ld = NULL; 61*0Sstevel@tonic-gate } 62*0Sstevel@tonic-gate } 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate return( ld ); 65*0Sstevel@tonic-gate } 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Function: prldap_install_routines(). 70*0Sstevel@tonic-gate * 71*0Sstevel@tonic-gate * Install NSPR I/O, threading, and DNS functions so they will be used by 72*0Sstevel@tonic-gate * 'ld'. 73*0Sstevel@tonic-gate * 74*0Sstevel@tonic-gate * If 'ld' is NULL, the functions are installed as the default functions 75*0Sstevel@tonic-gate * for all new LDAP * handles). 76*0Sstevel@tonic-gate * 77*0Sstevel@tonic-gate * Pass a non-zero value for the 'shared' parameter if you plan to use 78*0Sstevel@tonic-gate * this LDAP * handle from more than one thread. 79*0Sstevel@tonic-gate * 80*0Sstevel@tonic-gate * prldap_install_routines() returns an LDAP API error code (LDAP_SUCCESS 81*0Sstevel@tonic-gate * if all goes well). 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate int LDAP_CALL 84*0Sstevel@tonic-gate prldap_install_routines( LDAP *ld, int shared ) 85*0Sstevel@tonic-gate { 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate if ( prldap_install_io_functions( ld, shared ) != 0 88*0Sstevel@tonic-gate || prldap_install_thread_functions( ld, shared ) != 0 89*0Sstevel@tonic-gate || prldap_install_dns_functions( ld ) != 0 ) { 90*0Sstevel@tonic-gate return( ldap_get_lderrno( ld, NULL, NULL )); 91*0Sstevel@tonic-gate } 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 94*0Sstevel@tonic-gate } 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate #ifndef _SOLARIS_SDK /* Not used, left in to stay in sync with iplanet */ 98*0Sstevel@tonic-gate /* 99*0Sstevel@tonic-gate * Function: prldap_set_session_option(). 100*0Sstevel@tonic-gate * 101*0Sstevel@tonic-gate * Given an LDAP session handle or a session argument such is passed to 102*0Sstevel@tonic-gate * SOCKET, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, set 103*0Sstevel@tonic-gate * an option that affects the prldap layer. 104*0Sstevel@tonic-gate * 105*0Sstevel@tonic-gate * If 'ld' and 'session" are both NULL, the option is set as the default 106*0Sstevel@tonic-gate * for all new prldap sessions. 107*0Sstevel@tonic-gate * 108*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate int LDAP_CALL 111*0Sstevel@tonic-gate prldap_set_session_option( LDAP *ld, void *sessionarg, int option, ... ) 112*0Sstevel@tonic-gate { 113*0Sstevel@tonic-gate int rc = LDAP_SUCCESS; /* optimistic */ 114*0Sstevel@tonic-gate PRLDAPIOSessionArg *prsessp = NULL; 115*0Sstevel@tonic-gate va_list ap; 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate if ( NULL != ld ) { 118*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 119*0Sstevel@tonic-gate ( rc = prldap_session_arg_from_ld( ld, &prsessp ))) { 120*0Sstevel@tonic-gate return( rc ); 121*0Sstevel@tonic-gate } 122*0Sstevel@tonic-gate } else if ( NULL != sessionarg ) { 123*0Sstevel@tonic-gate prsessp = (PRLDAPIOSessionArg *)sessionarg; 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate va_start( ap, option ); 127*0Sstevel@tonic-gate switch ( option ) { 128*0Sstevel@tonic-gate case PRLDAP_OPT_IO_MAX_TIMEOUT: 129*0Sstevel@tonic-gate rc = prldap_set_io_max_timeout( prsessp, va_arg( ap, int )); 130*0Sstevel@tonic-gate break; 131*0Sstevel@tonic-gate default: 132*0Sstevel@tonic-gate rc = LDAP_PARAM_ERROR; 133*0Sstevel@tonic-gate } 134*0Sstevel@tonic-gate va_end( ap ); 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate return( rc ); 137*0Sstevel@tonic-gate } 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * Function: prldap_get_session_option(). 142*0Sstevel@tonic-gate * 143*0Sstevel@tonic-gate * Given an LDAP session handle or a session argument such is passed to 144*0Sstevel@tonic-gate * SOCKET, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, retrieve 145*0Sstevel@tonic-gate * the setting for an option that affects the prldap layer. 146*0Sstevel@tonic-gate * 147*0Sstevel@tonic-gate * If 'ld' and 'session" are both NULL, the default option value for all new 148*0Sstevel@tonic-gate * new prldap sessions is retrieved. 149*0Sstevel@tonic-gate * 150*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). 151*0Sstevel@tonic-gate */ 152*0Sstevel@tonic-gate int LDAP_CALL prldap_get_session_option( LDAP *ld, void *sessionarg, 153*0Sstevel@tonic-gate int option, ... ) 154*0Sstevel@tonic-gate { 155*0Sstevel@tonic-gate int rc = LDAP_SUCCESS; /* optimistic */ 156*0Sstevel@tonic-gate PRLDAPIOSessionArg *prsessp = NULL; 157*0Sstevel@tonic-gate va_list ap; 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate if ( NULL != ld ) { 160*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 161*0Sstevel@tonic-gate ( rc = prldap_session_arg_from_ld( ld, &prsessp ))) { 162*0Sstevel@tonic-gate return( rc ); 163*0Sstevel@tonic-gate } 164*0Sstevel@tonic-gate } else if ( NULL != sessionarg ) { 165*0Sstevel@tonic-gate prsessp = (PRLDAPIOSessionArg *)sessionarg; 166*0Sstevel@tonic-gate } 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate va_start( ap, option ); 169*0Sstevel@tonic-gate switch ( option ) { 170*0Sstevel@tonic-gate case PRLDAP_OPT_IO_MAX_TIMEOUT: 171*0Sstevel@tonic-gate rc = prldap_get_io_max_timeout( prsessp, va_arg( ap, int * )); 172*0Sstevel@tonic-gate break; 173*0Sstevel@tonic-gate default: 174*0Sstevel@tonic-gate rc = LDAP_PARAM_ERROR; 175*0Sstevel@tonic-gate } 176*0Sstevel@tonic-gate va_end( ap ); 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate return( rc ); 179*0Sstevel@tonic-gate } 180*0Sstevel@tonic-gate #endif /* !_SOLARIS_SDK */ 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate /* 184*0Sstevel@tonic-gate * Function: prldap_set_session_info(). 185*0Sstevel@tonic-gate * 186*0Sstevel@tonic-gate * Given an LDAP session handle, set some application-specific data. 187*0Sstevel@tonic-gate * 188*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). 189*0Sstevel@tonic-gate */ 190*0Sstevel@tonic-gate int LDAP_CALL 191*0Sstevel@tonic-gate prldap_set_session_info( LDAP *ld, void *sessionarg, PRLDAPSessionInfo *seip ) 192*0Sstevel@tonic-gate { 193*0Sstevel@tonic-gate int rc; 194*0Sstevel@tonic-gate PRLDAPIOSessionArg *prsessp; 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate if ( seip == NULL || PRLDAP_SESSIONINFO_SIZE != seip->seinfo_size ) { 197*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 198*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 199*0Sstevel@tonic-gate } 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate if ( NULL != ld ) { 202*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 203*0Sstevel@tonic-gate ( rc = prldap_session_arg_from_ld( ld, &prsessp ))) { 204*0Sstevel@tonic-gate return( rc ); 205*0Sstevel@tonic-gate } 206*0Sstevel@tonic-gate } else if ( NULL != sessionarg ) { 207*0Sstevel@tonic-gate prsessp = (PRLDAPIOSessionArg *)sessionarg; 208*0Sstevel@tonic-gate } else { 209*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 210*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 211*0Sstevel@tonic-gate } 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate prsessp->prsess_appdata = seip->seinfo_appdata; 214*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 215*0Sstevel@tonic-gate } 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate /* 219*0Sstevel@tonic-gate * Function: prldap_get_session_info(). 220*0Sstevel@tonic-gate * 221*0Sstevel@tonic-gate * Given an LDAP session handle, retrieve some application-specific data. 222*0Sstevel@tonic-gate * 223*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in 224*0Sstevel@tonic-gate * which case the fields in the structure that seip points to are filled in). 225*0Sstevel@tonic-gate */ 226*0Sstevel@tonic-gate int LDAP_CALL 227*0Sstevel@tonic-gate prldap_get_session_info( LDAP *ld, void *sessionarg, PRLDAPSessionInfo *seip ) 228*0Sstevel@tonic-gate { 229*0Sstevel@tonic-gate int rc; 230*0Sstevel@tonic-gate PRLDAPIOSessionArg *prsessp; 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate if ( seip == NULL || PRLDAP_SESSIONINFO_SIZE != seip->seinfo_size ) { 233*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 234*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 235*0Sstevel@tonic-gate } 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gate if ( NULL != ld ) { 238*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 239*0Sstevel@tonic-gate ( rc = prldap_session_arg_from_ld( ld, &prsessp ))) { 240*0Sstevel@tonic-gate return( rc ); 241*0Sstevel@tonic-gate } 242*0Sstevel@tonic-gate } else if ( NULL != sessionarg ) { 243*0Sstevel@tonic-gate prsessp = (PRLDAPIOSessionArg *)sessionarg; 244*0Sstevel@tonic-gate } else { 245*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 246*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 247*0Sstevel@tonic-gate } 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate seip->seinfo_appdata = prsessp->prsess_appdata; 250*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 251*0Sstevel@tonic-gate } 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate /* 255*0Sstevel@tonic-gate * Function: prldap_set_socket_info(). 256*0Sstevel@tonic-gate * 257*0Sstevel@tonic-gate * Given an integer fd and a void * argument such as those passed to the 258*0Sstevel@tonic-gate * extended I/O callback functions, set socket specific information. 259*0Sstevel@tonic-gate * 260*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). 261*0Sstevel@tonic-gate * 262*0Sstevel@tonic-gate * Note: it is only safe to change soinfo_prfd from within the SOCKET 263*0Sstevel@tonic-gate * extended I/O callback function. 264*0Sstevel@tonic-gate */ 265*0Sstevel@tonic-gate int LDAP_CALL 266*0Sstevel@tonic-gate prldap_set_socket_info( int fd, void *socketarg, PRLDAPSocketInfo *soip ) 267*0Sstevel@tonic-gate { 268*0Sstevel@tonic-gate PRLDAPIOSocketArg *prsockp; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate if ( NULL == socketarg || NULL == soip || 271*0Sstevel@tonic-gate PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) { 272*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 273*0Sstevel@tonic-gate } 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate prsockp = (PRLDAPIOSocketArg *)socketarg; 276*0Sstevel@tonic-gate prsockp->prsock_prfd = soip->soinfo_prfd; 277*0Sstevel@tonic-gate prsockp->prsock_appdata = soip->soinfo_appdata; 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 280*0Sstevel@tonic-gate } 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate /* 284*0Sstevel@tonic-gate * Function: prldap_get_socket_info(). 285*0Sstevel@tonic-gate * 286*0Sstevel@tonic-gate * Given an integer fd and a void * argument such as those passed to the 287*0Sstevel@tonic-gate * extended I/O callback functions, retrieve socket specific information. 288*0Sstevel@tonic-gate * 289*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in 290*0Sstevel@tonic-gate * which case the fields in the structure that soip points to are filled in). 291*0Sstevel@tonic-gate */ 292*0Sstevel@tonic-gate int LDAP_CALL 293*0Sstevel@tonic-gate prldap_get_socket_info( int fd, void *socketarg, PRLDAPSocketInfo *soip ) 294*0Sstevel@tonic-gate { 295*0Sstevel@tonic-gate PRLDAPIOSocketArg *prsockp; 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate if ( NULL == socketarg || NULL == soip || 298*0Sstevel@tonic-gate PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) { 299*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 300*0Sstevel@tonic-gate } 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate prsockp = (PRLDAPIOSocketArg *)socketarg; 303*0Sstevel@tonic-gate soip->soinfo_prfd = prsockp->prsock_prfd; 304*0Sstevel@tonic-gate soip->soinfo_appdata = prsockp->prsock_appdata; 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 307*0Sstevel@tonic-gate } 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate /* 310*0Sstevel@tonic-gate * Function: prldap_get_default_socket_info(). 311*0Sstevel@tonic-gate * 312*0Sstevel@tonic-gate * Given an LDAP session handle, retrieve socket specific information. 313*0Sstevel@tonic-gate * If ld is NULL, LDAP_PARAM_ERROR is returned. 314*0Sstevel@tonic-gate * 315*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in 316*0Sstevel@tonic-gate * which case the fields in the structure that soip points to are filled in). 317*0Sstevel@tonic-gate */ 318*0Sstevel@tonic-gate int LDAP_CALL 319*0Sstevel@tonic-gate prldap_get_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip ) 320*0Sstevel@tonic-gate { 321*0Sstevel@tonic-gate int rc; 322*0Sstevel@tonic-gate PRLDAPIOSocketArg *prsockp; 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate if ( NULL == soip || PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) { 326*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 327*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 328*0Sstevel@tonic-gate } 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate if ( NULL != ld ) { 331*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 332*0Sstevel@tonic-gate ( rc = prldap_socket_arg_from_ld( ld, &prsockp ))) { 333*0Sstevel@tonic-gate return( rc ); 334*0Sstevel@tonic-gate } 335*0Sstevel@tonic-gate } else { 336*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 337*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 338*0Sstevel@tonic-gate } 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gate soip->soinfo_prfd = prsockp->prsock_prfd; 341*0Sstevel@tonic-gate soip->soinfo_appdata = prsockp->prsock_appdata; 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 344*0Sstevel@tonic-gate } 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate /* 348*0Sstevel@tonic-gate * Function: prldap_set_default_socket_info(). 349*0Sstevel@tonic-gate * 350*0Sstevel@tonic-gate * Given an LDAP session handle, set socket specific information. 351*0Sstevel@tonic-gate * If ld is NULL, LDAP_PARAM_ERROR is returned. 352*0Sstevel@tonic-gate * 353*0Sstevel@tonic-gate * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in 354*0Sstevel@tonic-gate * which case the fields in the structure that soip points to are filled in). 355*0Sstevel@tonic-gate */ 356*0Sstevel@tonic-gate int LDAP_CALL 357*0Sstevel@tonic-gate prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip ) 358*0Sstevel@tonic-gate { 359*0Sstevel@tonic-gate int rc; 360*0Sstevel@tonic-gate PRLDAPIOSocketArg *prsockp; 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate if ( NULL == soip || PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) { 364*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 365*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 366*0Sstevel@tonic-gate } 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate if ( NULL != ld ) { 369*0Sstevel@tonic-gate if ( LDAP_SUCCESS != 370*0Sstevel@tonic-gate ( rc = prldap_socket_arg_from_ld( ld, &prsockp ))) { 371*0Sstevel@tonic-gate return( rc ); 372*0Sstevel@tonic-gate } 373*0Sstevel@tonic-gate } else { 374*0Sstevel@tonic-gate ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); 375*0Sstevel@tonic-gate return( LDAP_PARAM_ERROR ); 376*0Sstevel@tonic-gate } 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate prsockp->prsock_prfd = soip->soinfo_prfd; 379*0Sstevel@tonic-gate prsockp->prsock_appdata = soip->soinfo_appdata; 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gate return( LDAP_SUCCESS ); 382*0Sstevel@tonic-gate } 383