2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
24 #include "wine/debug.h"
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 ULONG WLDAP32_ldap_count_values_len( struct WLDAP32_berval **vals )
46 ULONG ret = LDAP_NOT_SUPPORTED;
49 TRACE( "(%p)\n", vals );
50 ret = ldap_count_values_len( (struct berval **)vals );
56 ULONG ldap_count_valuesA( PCHAR *vals )
58 ULONG ret = LDAP_NOT_SUPPORTED;
62 TRACE( "(%p)\n", vals );
65 valsW = strarrayAtoW( vals );
66 if (!valsW) return WLDAP32_LDAP_NO_MEMORY;
69 ret = ldap_count_valuesW( valsW );
70 strarrayfreeW( valsW );
76 ULONG ldap_count_valuesW( PWCHAR *vals )
78 ULONG ret = LDAP_NOT_SUPPORTED;
82 TRACE( "(%p)\n", vals );
85 valsU = strarrayWtoU( vals );
86 if (!valsU) return WLDAP32_LDAP_NO_MEMORY;
89 ret = ldap_count_values( valsU );
90 strarrayfreeU( valsU );
96 PCHAR *ldap_get_valuesA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PCHAR attr )
100 WCHAR *attrW = NULL, **retW;
102 TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_a(attr) );
104 if (!ld || !entry || !attr) return NULL;
106 attrW = strAtoW( attr );
107 if (!attrW) return NULL;
109 retW = ldap_get_valuesW( ld, entry, attrW );
111 ret = strarrayWtoA( retW );
112 ldap_value_freeW( retW );
119 PWCHAR *ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PWCHAR attr )
123 char *attrU = NULL, **retU;
125 TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
127 if (!ld || !entry || !attr) return NULL;
129 attrU = strWtoU( attr );
130 if (!attrU) return NULL;
132 retU = ldap_get_values( ld, entry, attrU );
134 ret = strarrayUtoW( retU );
135 ldap_value_free( retU );
142 struct WLDAP32_berval **ldap_get_values_lenA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
147 struct WLDAP32_berval **ret;
149 TRACE( "(%p, %p, %s)\n", ld, message, debugstr_a(attr) );
151 if (!ld || !message || !attr) return NULL;
153 attrW = strAtoW( attr );
154 if (!attrW) return NULL;
156 ret = ldap_get_values_lenW( ld, message, attrW );
165 struct WLDAP32_berval **ldap_get_values_lenW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
172 TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
174 if (!ld || !message || !attr) return NULL;
176 attrU = strWtoU( attr );
177 if (!attrU) return NULL;
179 ret = ldap_get_values_len( ld, message, attrU );
182 return (struct WLDAP32_berval **)ret;
188 ULONG WLDAP32_ldap_value_free_len( struct WLDAP32_berval **vals )
192 TRACE( "(%p)\n", vals );
193 ldap_value_free_len( (struct berval **)vals );
199 ULONG ldap_value_freeA( PCHAR *vals )
201 TRACE( "(%p)\n", vals );
203 strarrayfreeA( vals );
207 ULONG ldap_value_freeW( PWCHAR *vals )
209 TRACE( "(%p)\n", vals );
211 strarrayfreeW( vals );