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
38 #include "winldap_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 PCHAR ldap_dn2ufnA( PCHAR dn )
49 TRACE( "(%s)\n", debugstr_a(dn) );
52 if (!dnW) return NULL;
54 retW = ldap_dn2ufnW( dnW );
55 ret = strWtoA( retW );
58 ldap_memfreeW( retW );
64 PWCHAR ldap_dn2ufnW( PWCHAR dn )
70 TRACE( "(%s)\n", debugstr_w(dn) );
73 if (!dnU) return NULL;
75 retU = ldap_dn2ufn( dnU );
76 ret = strUtoW( retU );
85 PCHAR *ldap_explode_dnA( PCHAR dn, ULONG notypes )
91 TRACE( "(%s, 0x%08lx)\n", debugstr_a(dn), notypes );
94 if (!dnW) return NULL;
96 retW = ldap_explode_dnW( dnW, notypes );
97 ret = strarrayWtoA( retW );
100 ldap_value_freeW( retW );
106 PWCHAR *ldap_explode_dnW( PWCHAR dn, ULONG notypes )
112 TRACE( "(%s, 0x%08lx)\n", debugstr_w(dn), notypes );
115 if (!dnU) return NULL;
117 retU = ldap_explode_dn( dnU, notypes );
118 ret = strarrayUtoW( retU );
121 ldap_value_free( retU );
127 PCHAR ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
133 TRACE( "(%p, %p)\n", ld, entry );
135 if (!ld || !entry) return NULL;
137 retW = ldap_get_dnW( ld, entry );
139 ret = strWtoA( retW );
140 ldap_memfreeW( retW );
146 PWCHAR ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
152 TRACE( "(%p, %p)\n", ld, entry );
154 if (!ld || !entry) return NULL;
156 retU = ldap_get_dn( ld, entry );
158 ret = strUtoW( retU );
159 ldap_memfree( retU );
165 ULONG ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
167 ULONG ret = LDAP_SUCCESS;
169 PWCHAR ufnW = NULL, dnW = NULL;
171 TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
173 if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
178 ufnW = strAtoW( ufn );
179 if (!ufnW) return WLDAP32_LDAP_NO_MEMORY;
182 ret = ldap_ufn2dnW( ufnW, &dnW );
185 *dn = strWtoA( dnW );
186 if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
190 ldap_memfreeW( dnW );
196 ULONG ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
198 ULONG ret = LDAP_SUCCESS;
202 TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
204 if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
209 ufnU = strWtoU( ufn );
210 if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
212 /* FIXME: do more than just a copy */
213 *dn = strUtoW( ufnU );
214 if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;