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
22 #include "wine/port.h"
33 #include "winldap_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
39 /***********************************************************************
40 * ldap_dn2ufnA (WLDAP32.@)
44 PCHAR CDECL
ldap_dn2ufnA( PCHAR dn
)
50 TRACE( "(%s)\n", debugstr_a(dn
) );
53 if (!dnW
) return NULL
;
55 retW
= ldap_dn2ufnW( dnW
);
56 ret
= strWtoA( retW
);
59 ldap_memfreeW( retW
);
65 /***********************************************************************
66 * ldap_dn2ufnW (WLDAP32.@)
68 * Convert a DN to a user-friendly name.
71 * dn [I] DN to convert.
74 * Success: Pointer to a string containing the user-friendly name.
78 * Free the string with ldap_memfree.
80 PWCHAR CDECL
ldap_dn2ufnW( PWCHAR dn
)
86 TRACE( "(%s)\n", debugstr_w(dn
) );
89 if (!dnU
) return NULL
;
91 retU
= ldap_dn2ufn( dnU
);
92 ret
= strUtoW( retU
);
101 /***********************************************************************
102 * ldap_explode_dnA (WLDAP32.@)
104 * See ldap_explode_dnW.
106 PCHAR
* CDECL
ldap_explode_dnA( PCHAR dn
, ULONG notypes
)
112 TRACE( "(%s, 0x%08x)\n", debugstr_a(dn
), notypes
);
115 if (!dnW
) return NULL
;
117 retW
= ldap_explode_dnW( dnW
, notypes
);
118 ret
= strarrayWtoA( retW
);
121 ldap_value_freeW( retW
);
127 /***********************************************************************
128 * ldap_explode_dnW (WLDAP32.@)
130 * Break up a DN into its components.
133 * dn [I] DN to break up.
134 * notypes [I] Remove attribute type information from the components.
137 * Success: Pointer to a NULL-terminated array that contains the DN
142 * Free the string array with ldap_value_free.
144 PWCHAR
* CDECL
ldap_explode_dnW( PWCHAR dn
, ULONG notypes
)
150 TRACE( "(%s, 0x%08x)\n", debugstr_w(dn
), notypes
);
153 if (!dnU
) return NULL
;
155 retU
= ldap_explode_dn( dnU
, notypes
);
156 ret
= strarrayUtoW( retU
);
159 ldap_memvfree( (void **)retU
);
165 /***********************************************************************
166 * ldap_get_dnA (WLDAP32.@)
170 PCHAR CDECL
ldap_get_dnA( WLDAP32_LDAP
*ld
, WLDAP32_LDAPMessage
*entry
)
176 TRACE( "(%p, %p)\n", ld
, entry
);
178 if (!ld
|| !entry
) return NULL
;
180 retW
= ldap_get_dnW( ld
, entry
);
182 ret
= strWtoA( retW
);
183 ldap_memfreeW( retW
);
189 /***********************************************************************
190 * ldap_get_dnW (WLDAP32.@)
192 * Retrieve the DN from a given LDAP message.
195 * ld [I] Pointer to an LDAP context.
196 * entry [I] LDAPMessage structure to retrieve the DN from.
199 * Success: Pointer to a string that contains the DN.
203 * Free the string with ldap_memfree.
205 PWCHAR CDECL
ldap_get_dnW( WLDAP32_LDAP
*ld
, WLDAP32_LDAPMessage
*entry
)
211 TRACE( "(%p, %p)\n", ld
, entry
);
213 if (!ld
|| !entry
) return NULL
;
215 retU
= ldap_get_dn( ld
, entry
);
217 ret
= strUtoW( retU
);
218 ldap_memfree( retU
);
224 /***********************************************************************
225 * ldap_ufn2dnA (WLDAP32.@)
229 ULONG CDECL
ldap_ufn2dnA( PCHAR ufn
, PCHAR
*dn
)
231 ULONG ret
= WLDAP32_LDAP_SUCCESS
;
233 PWCHAR ufnW
= NULL
, dnW
= NULL
;
235 TRACE( "(%s, %p)\n", debugstr_a(ufn
), dn
);
237 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
242 ufnW
= strAtoW( ufn
);
243 if (!ufnW
) return WLDAP32_LDAP_NO_MEMORY
;
246 ret
= ldap_ufn2dnW( ufnW
, &dnW
);
249 *dn
= strWtoA( dnW
);
250 if (!*dn
) ret
= WLDAP32_LDAP_NO_MEMORY
;
254 ldap_memfreeW( dnW
);
260 /***********************************************************************
261 * ldap_ufn2dnW (WLDAP32.@)
263 * Convert a user-friendly name to a DN.
266 * ufn [I] User-friendly name to convert.
267 * dn [O] Receives a pointer to a string containing the DN.
270 * Success: LDAP_SUCCESS
271 * Failure: An LDAP error code.
274 * Free the string with ldap_memfree.
276 ULONG CDECL
ldap_ufn2dnW( PWCHAR ufn
, PWCHAR
*dn
)
278 ULONG ret
= WLDAP32_LDAP_SUCCESS
;
282 TRACE( "(%s, %p)\n", debugstr_w(ufn
), dn
);
284 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
289 ufnU
= strWtoU( ufn
);
290 if (!ufnU
) return WLDAP32_LDAP_NO_MEMORY
;
292 /* FIXME: do more than just a copy */
293 *dn
= strUtoW( ufnU
);
294 if (!*dn
) ret
= WLDAP32_LDAP_NO_MEMORY
;