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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
28 #include "winldap_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
32 /***********************************************************************
33 * ldap_dn2ufnA (WLDAP32.@)
37 char * CDECL
ldap_dn2ufnA( char *dn
)
42 TRACE( "(%s)\n", debugstr_a(dn
) );
44 if (!(dnW
= strAtoW( dn
))) return NULL
;
46 retW
= ldap_dn2ufnW( dnW
);
47 ret
= strWtoA( retW
);
50 ldap_memfreeW( retW
);
54 /***********************************************************************
55 * ldap_dn2ufnW (WLDAP32.@)
57 * Convert a DN to a user-friendly name.
60 * dn [I] DN to convert.
63 * Success: Pointer to a string containing the user-friendly name.
67 * Free the string with ldap_memfree.
69 WCHAR
* CDECL
ldap_dn2ufnW( WCHAR
*dn
)
74 TRACE( "(%s)\n", debugstr_w(dn
) );
76 if (!(dnU
= strWtoU( dn
))) return NULL
;
78 retU
= ldap_funcs
->fn_ldap_dn2ufn( dnU
);
79 ret
= strUtoW( retU
);
82 ldap_funcs
->fn_ldap_memfree( retU
);
86 /***********************************************************************
87 * ldap_explode_dnA (WLDAP32.@)
89 * See ldap_explode_dnW.
91 char ** CDECL
ldap_explode_dnA( char *dn
, ULONG notypes
)
96 TRACE( "(%s, 0x%08x)\n", debugstr_a(dn
), notypes
);
98 if (!(dnW
= strAtoW( dn
))) return NULL
;
100 retW
= ldap_explode_dnW( dnW
, notypes
);
101 ret
= strarrayWtoA( retW
);
104 ldap_value_freeW( retW
);
108 /***********************************************************************
109 * ldap_explode_dnW (WLDAP32.@)
111 * Break up a DN into its components.
114 * dn [I] DN to break up.
115 * notypes [I] Remove attribute type information from the components.
118 * Success: Pointer to a NULL-terminated array that contains the DN
123 * Free the string array with ldap_value_free.
125 WCHAR
** CDECL
ldap_explode_dnW( WCHAR
*dn
, ULONG notypes
)
130 TRACE( "(%s, 0x%08x)\n", debugstr_w(dn
), notypes
);
132 if (!(dnU
= strWtoU( dn
))) return NULL
;
134 retU
= ldap_funcs
->fn_ldap_explode_dn( dnU
, notypes
);
135 ret
= strarrayUtoW( retU
);
138 ldap_funcs
->fn_ldap_memvfree( (void **)retU
);
142 /***********************************************************************
143 * ldap_get_dnA (WLDAP32.@)
147 char * CDECL
ldap_get_dnA( LDAP
*ld
, LDAPMessage
*entry
)
152 TRACE( "(%p, %p)\n", ld
, entry
);
154 if (!ld
|| !entry
) return NULL
;
156 retW
= ldap_get_dnW( ld
, entry
);
158 ret
= strWtoA( retW
);
159 ldap_memfreeW( retW
);
163 /***********************************************************************
164 * ldap_get_dnW (WLDAP32.@)
166 * Retrieve the DN from a given LDAP message.
169 * ld [I] Pointer to an LDAP context.
170 * entry [I] LDAPMessage structure to retrieve the DN from.
173 * Success: Pointer to a string that contains the DN.
177 * Free the string with ldap_memfree.
179 WCHAR
* CDECL
ldap_get_dnW( LDAP
*ld
, LDAPMessage
*entry
)
184 TRACE( "(%p, %p)\n", ld
, entry
);
186 if (!ld
|| !entry
) return NULL
;
188 retU
= ldap_funcs
->fn_ldap_get_dn( CTX(ld
), MSG(entry
) );
190 ret
= strUtoW( retU
);
191 ldap_funcs
->fn_ldap_memfree( retU
);
195 /***********************************************************************
196 * ldap_ufn2dnA (WLDAP32.@)
200 ULONG CDECL
ldap_ufn2dnA( char *ufn
, char **dn
)
203 WCHAR
*ufnW
= NULL
, *dnW
= NULL
;
205 TRACE( "(%s, %p)\n", debugstr_a(ufn
), dn
);
207 if (!dn
) return LDAP_PARAM_ERROR
;
210 if (ufn
&& !(ufnW
= strAtoW( ufn
))) return LDAP_NO_MEMORY
;
212 ret
= ldap_ufn2dnW( ufnW
, &dnW
);
216 if (!(str
= strWtoA( dnW
))) ret
= LDAP_NO_MEMORY
;
221 ldap_memfreeW( dnW
);
225 /***********************************************************************
226 * ldap_ufn2dnW (WLDAP32.@)
228 * Convert a user-friendly name to a DN.
231 * ufn [I] User-friendly name to convert.
232 * dn [O] Receives a pointer to a string containing the DN.
235 * Success: LDAP_SUCCESS
236 * Failure: An LDAP error code.
239 * Free the string with ldap_memfree.
241 ULONG CDECL
ldap_ufn2dnW( WCHAR
*ufn
, WCHAR
**dn
)
243 ULONG ret
= LDAP_SUCCESS
;
246 TRACE( "(%s, %p)\n", debugstr_w(ufn
), dn
);
248 if (!dn
) return LDAP_PARAM_ERROR
;
254 if (!(ufnU
= strWtoU( ufn
))) return LDAP_NO_MEMORY
;
256 /* FIXME: do more than just a copy */
257 if (!(str
= strUtoW( ufnU
))) ret
= LDAP_NO_MEMORY
;