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
23 #include "wine/port.h"
24 #include "wine/debug.h"
36 #include "winldap_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
41 /***********************************************************************
42 * ldap_dn2ufnA (WLDAP32.@)
46 PCHAR CDECL
ldap_dn2ufnA( PCHAR dn
)
52 TRACE( "(%s)\n", debugstr_a(dn
) );
55 if (!dnW
) return NULL
;
57 retW
= ldap_dn2ufnW( dnW
);
58 ret
= strWtoA( retW
);
61 ldap_memfreeW( retW
);
67 /***********************************************************************
68 * ldap_dn2ufnW (WLDAP32.@)
70 * Convert a DN to a user-friendly name.
73 * dn [I] DN to convert.
76 * Success: Pointer to a string containing the user-friendly name.
80 * Free the string with ldap_memfree.
82 PWCHAR CDECL
ldap_dn2ufnW( PWCHAR dn
)
88 TRACE( "(%s)\n", debugstr_w(dn
) );
91 if (!dnU
) return NULL
;
93 retU
= ldap_dn2ufn( dnU
);
94 ret
= strUtoW( retU
);
103 /***********************************************************************
104 * ldap_explode_dnA (WLDAP32.@)
106 * See ldap_explode_dnW.
108 PCHAR
* CDECL
ldap_explode_dnA( PCHAR dn
, ULONG notypes
)
114 TRACE( "(%s, 0x%08x)\n", debugstr_a(dn
), notypes
);
117 if (!dnW
) return NULL
;
119 retW
= ldap_explode_dnW( dnW
, notypes
);
120 ret
= strarrayWtoA( retW
);
123 ldap_value_freeW( retW
);
129 /***********************************************************************
130 * ldap_explode_dnW (WLDAP32.@)
132 * Break up a DN into its components.
135 * dn [I] DN to break up.
136 * notypes [I] Remove attribute type information from the components.
139 * Success: Pointer to a NULL-terminated array that contains the DN
144 * Free the string array with ldap_value_free.
146 PWCHAR
* CDECL
ldap_explode_dnW( PWCHAR dn
, ULONG notypes
)
152 TRACE( "(%s, 0x%08x)\n", debugstr_w(dn
), notypes
);
155 if (!dnU
) return NULL
;
157 retU
= ldap_explode_dn( dnU
, notypes
);
158 ret
= strarrayUtoW( retU
);
161 ldap_memvfree( (void **)retU
);
167 /***********************************************************************
168 * ldap_get_dnA (WLDAP32.@)
172 PCHAR CDECL
ldap_get_dnA( WLDAP32_LDAP
*ld
, WLDAP32_LDAPMessage
*entry
)
178 TRACE( "(%p, %p)\n", ld
, entry
);
180 if (!ld
|| !entry
) return NULL
;
182 retW
= ldap_get_dnW( ld
, entry
);
184 ret
= strWtoA( retW
);
185 ldap_memfreeW( retW
);
191 /***********************************************************************
192 * ldap_get_dnW (WLDAP32.@)
194 * Retrieve the DN from a given LDAP message.
197 * ld [I] Pointer to an LDAP context.
198 * entry [I] LDAPMessage structure to retrieve the DN from.
201 * Success: Pointer to a string that contains the DN.
205 * Free the string with ldap_memfree.
207 PWCHAR CDECL
ldap_get_dnW( WLDAP32_LDAP
*ld
, WLDAP32_LDAPMessage
*entry
)
213 TRACE( "(%p, %p)\n", ld
, entry
);
215 if (!ld
|| !entry
) return NULL
;
217 retU
= ldap_get_dn( ld
, entry
);
219 ret
= strUtoW( retU
);
220 ldap_memfree( retU
);
226 /***********************************************************************
227 * ldap_ufn2dnA (WLDAP32.@)
231 ULONG CDECL
ldap_ufn2dnA( PCHAR ufn
, PCHAR
*dn
)
233 ULONG ret
= WLDAP32_LDAP_SUCCESS
;
235 PWCHAR ufnW
= NULL
, dnW
= NULL
;
237 TRACE( "(%s, %p)\n", debugstr_a(ufn
), dn
);
239 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
244 ufnW
= strAtoW( ufn
);
245 if (!ufnW
) return WLDAP32_LDAP_NO_MEMORY
;
248 ret
= ldap_ufn2dnW( ufnW
, &dnW
);
251 *dn
= strWtoA( dnW
);
252 if (!*dn
) ret
= WLDAP32_LDAP_NO_MEMORY
;
256 ldap_memfreeW( dnW
);
262 /***********************************************************************
263 * ldap_ufn2dnW (WLDAP32.@)
265 * Convert a user-friendly name to a DN.
268 * ufn [I] User-friendly name to convert.
269 * dn [O] Receives a pointer to a string containing the DN.
272 * Success: LDAP_SUCCESS
273 * Failure: An LDAP error code.
276 * Free the string with ldap_memfree.
278 ULONG CDECL
ldap_ufn2dnW( PWCHAR ufn
, PWCHAR
*dn
)
280 ULONG ret
= WLDAP32_LDAP_SUCCESS
;
284 TRACE( "(%s, %p)\n", debugstr_w(ufn
), dn
);
286 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
291 ufnU
= strWtoU( ufn
);
292 if (!ufnU
) return WLDAP32_LDAP_NO_MEMORY
;
294 /* FIXME: do more than just a copy */
295 *dn
= strUtoW( ufnU
);
296 if (!*dn
) ret
= WLDAP32_LDAP_NO_MEMORY
;