/*********************************************************************** * ldap_parse_resultW (WLDAP32.@) * * Parse a result message. * * PARAMS * ld [I] Pointer to an LDAP context. * result [I] Result message. * retcode [O] Return code for the server operation. * matched [O] DNs matched in the operation. * error [O] Error message for the operation. * referrals [O] Referrals found in the result message. * serverctrls [O] Controls used in the operation. * free [I] Free the result message? * * RETURNS * Success: LDAP_SUCCESS * Failure: An LDAP error code. * * NOTES * Free the DNs and error message with ldap_memfree. Free * the referrals with ldap_value_free and the controls with * ldap_controls_free. Pass a nonzero value for 'free' or call * ldap_msgfree to free the result message. */ ULONG CDECL ldap_parse_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result, ULONG *retcode, PWCHAR *matched, PWCHAR *error, PWCHAR **referrals, PLDAPControlW **serverctrls, BOOLEAN free ) { ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; #ifdef HAVE_LDAP char *matchedU = NULL, *errorU = NULL, **referralsU = NULL; LDAPControl **serverctrlsU = NULL; TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode, matched, error, referrals, serverctrls, free ); if (!ld) return WLDAP32_LDAP_PARAM_ERROR; ret = map_error( ldap_parse_result( ld, result, (int *)retcode, &matchedU, &errorU, &referralsU, &serverctrlsU, free )); if (matched) *matched = strUtoW( matchedU ); if (error) *error = strUtoW( errorU ); if (referrals) *referrals = strarrayUtoW( referralsU ); if (serverctrls) *serverctrls = controlarrayUtoW( serverctrlsU ); ldap_memfree( matchedU ); ldap_memfree( errorU ); strarrayfreeU( referralsU ); ldap_controls_free( serverctrlsU ); #endif return ret; }
/*********************************************************************** * ldap_get_valuesW (WLDAP32.@) * * Retrieve string values for a given attribute. * * PARAMS * ld [I] Pointer to an LDAP context. * entry [I] Entry to retrieve values from. * attr [I] Attribute to retrieve values for. * * RETURNS * Success: Pointer to a character array holding the values. * Failure: NULL * * NOTES * Call ldap_get_valuesW with the result of a call to * ldap_first_entry or ldap_next_entry. Free the returned * array with a call to ldap_value_freeW. */ PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PWCHAR attr ) { PWCHAR *ret = NULL; #ifdef HAVE_LDAP char *attrU = NULL, **retU; struct berval **bv; TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) ); if (!ld || !entry || !attr) return NULL; attrU = strWtoU( attr ); if (!attrU) return NULL; bv = ldap_get_values_len( ld, entry, attrU ); retU = bv2str_array( bv ); ret = strarrayUtoW( retU ); ldap_value_free_len( bv ); strarrayfreeU( retU ); strfreeU( attrU ); #endif return ret; }
/*********************************************************************** * ldap_search_extW (WLDAP32.@) * * Search a directory tree (asynchronous operation). * * PARAMS * ld [I] Pointer to an LDAP context. * base [I] Starting point for the search. * scope [I] Search scope. One of LDAP_SCOPE_BASE, * LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE. * filter [I] Search filter. * attrs [I] Attributes to return. * attrsonly [I] Return no values, only attributes. * serverctrls [I] Array of LDAP server controls. * clientctrls [I] Array of LDAP client controls. * timelimit [I] Timeout in seconds. * sizelimit [I] Maximum number of entries to return. Zero means unlimited. * message [O] Message ID of the search operation. * * RETURNS * Success: LDAP_SUCCESS * Failure: An LDAP error code. * * NOTES * Call ldap_result with the message ID to get the result of * the operation. Cancel the operation by calling ldap_abandon * with the message ID. */ ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message ) { ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; #ifdef HAVE_LDAP char *baseU = NULL, *filterU = NULL, **attrsU = NULL; LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; struct timeval tv, *tvp = NULL; ret = WLDAP32_LDAP_NO_MEMORY; TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, message ); if (!ld) return ~0u; if (base) { baseU = strWtoU( base ); if (!baseU) goto exit; } if (filter) { filterU = strWtoU( filter ); if (!filterU) goto exit; } if (attrs) { attrsU = strarrayWtoU( attrs ); if (!attrsU) goto exit; } if (serverctrls) { serverctrlsU = controlarrayWtoU( serverctrls ); if (!serverctrlsU) goto exit; } if (clientctrls) { clientctrlsU = controlarrayWtoU( clientctrls ); if (!clientctrlsU) goto exit; } if (timelimit) { tv.tv_sec = timelimit; tv.tv_usec = 0; tvp = &tv; } ret = map_error( ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly, serverctrlsU, clientctrlsU, tvp, sizelimit, (int *)message )); exit: strfreeU( baseU ); strfreeU( filterU ); strarrayfreeU( attrsU ); controlarrayfreeU( serverctrlsU ); controlarrayfreeU( clientctrlsU ); #endif return ret; }
/*********************************************************************** * ldap_search_ext_sW (WLDAP32.@) * * Search a directory tree (synchronous operation). * * PARAMS * ld [I] Pointer to an LDAP context. * base [I] Starting point for the search. * scope [I] Search scope. One of LDAP_SCOPE_BASE, * LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE. * filter [I] Search filter. * attrs [I] Attributes to return. * attrsonly [I] Return no values, only attributes. * serverctrls [I] Array of LDAP server controls. * clientctrls [I] Array of LDAP client controls. * timeout [I] Timeout in seconds. * sizelimit [I] Maximum number of entries to return. Zero means unlimited. * res [O] Results of the search operation. * * RETURNS * Success: LDAP_SUCCESS * Failure: An LDAP error code. * * NOTES * Call ldap_msgfree to free the results. */ ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res ) { ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; #ifdef HAVE_LDAP char *baseU = NULL, *filterU = NULL, **attrsU = NULL; LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; ret = WLDAP32_LDAP_NO_MEMORY; TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timeout, sizelimit, res ); if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR; if (base) { baseU = strWtoU( base ); if (!baseU) goto exit; } if (filter) { filterU = strWtoU( filter ); if (!filterU) goto exit; } if (attrs) { attrsU = strarrayWtoU( attrs ); if (!attrsU) goto exit; } if (serverctrls) { serverctrlsU = controlarrayWtoU( serverctrls ); if (!serverctrlsU) goto exit; } if (clientctrls) { clientctrlsU = controlarrayWtoU( clientctrls ); if (!clientctrlsU) goto exit; } ret = map_error( ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly, serverctrlsU, clientctrlsU, (struct timeval *)timeout, sizelimit, res )); exit: strfreeU( baseU ); strfreeU( filterU ); strarrayfreeU( attrsU ); controlarrayfreeU( serverctrlsU ); controlarrayfreeU( clientctrlsU ); #endif return ret; }
/*********************************************************************** * ldap_searchW (WLDAP32.@) * * Search a directory tree (asynchronous operation). * * PARAMS * ld [I] Pointer to an LDAP context. * base [I] Starting point for the search. * scope [I] Search scope. One of LDAP_SCOPE_BASE, * LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE. * filter [I] Search filter. * attrs [I] Attributes to return. * attrsonly [I] Return no values, only attributes. * * RETURNS * Success: Message ID of the search operation. * Failure: ~0u * * NOTES * Call ldap_result with the message ID to get the result of * the operation. Cancel the operation by calling ldap_abandon * with the message ID. */ ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter, PWCHAR attrs[], ULONG attrsonly ) { ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; #ifdef HAVE_LDAP char *baseU = NULL, *filterU = NULL, **attrsU = NULL; int msg; ret = WLDAP32_LDAP_NO_MEMORY; TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly ); if (!ld) return ~0u; if (base) { baseU = strWtoU( base ); if (!baseU) goto exit; } if (filter) { filterU = strWtoU( filter ); if (!filterU) goto exit; } if (attrs) { attrsU = strarrayWtoU( attrs ); if (!attrsU) goto exit; } ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly, NULL, NULL, NULL, 0, &msg ); if (ret == LDAP_SUCCESS) ret = msg; else ret = ~0u; exit: strfreeU( baseU ); strfreeU( filterU ); strarrayfreeU( attrsU ); #endif return ret; }
/*********************************************************************** * ldap_search_stW (WLDAP32.@) * * Search a directory tree (synchronous operation). * * PARAMS * ld [I] Pointer to an LDAP context. * base [I] Starting point for the search. * scope [I] Search scope. One of LDAP_SCOPE_BASE, * LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE. * filter [I] Search filter. * attrs [I] Attributes to return. * attrsonly [I] Return no values, only attributes. * timeout [I] Timeout in seconds. * res [O] Results of the search operation. * * RETURNS * Success: LDAP_SUCCESS * Failure: An LDAP error code. * * NOTES * Call ldap_msgfree to free the results. */ ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope, const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, struct l_timeval *timeout, WLDAP32_LDAPMessage **res ) { ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; #ifdef HAVE_LDAP char *baseU = NULL, *filterU = NULL, **attrsU = NULL; ret = WLDAP32_LDAP_NO_MEMORY; TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly, timeout, res ); if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR; if (base) { baseU = strWtoU( base ); if (!baseU) goto exit; } if (filter) { filterU = strWtoU( filter ); if (!filterU) goto exit; } if (attrs) { attrsU = strarrayWtoU( attrs ); if (!attrsU) goto exit; } ret = map_error( ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly, NULL, NULL, (struct timeval *)timeout, 0, res )); exit: strfreeU( baseU ); strfreeU( filterU ); strarrayfreeU( attrsU ); #endif return ret; }