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
)))
78 struct ldap_dn2ufn_params params
= { dnU
, &retU
};
79 LDAP_CALL( ldap_dn2ufn
, ¶ms
);
81 ret
= strUtoW( retU
);
84 LDAP_CALL( ldap_memfree
, retU
);
89 /***********************************************************************
90 * ldap_explode_dnA (WLDAP32.@)
92 * See ldap_explode_dnW.
94 char ** CDECL
ldap_explode_dnA( char *dn
, ULONG notypes
)
99 TRACE( "(%s, 0x%08x)\n", debugstr_a(dn
), notypes
);
101 if (!(dnW
= strAtoW( dn
))) return NULL
;
103 retW
= ldap_explode_dnW( dnW
, notypes
);
104 ret
= strarrayWtoA( retW
);
107 ldap_value_freeW( retW
);
111 /***********************************************************************
112 * ldap_explode_dnW (WLDAP32.@)
114 * Break up a DN into its components.
117 * dn [I] DN to break up.
118 * notypes [I] Remove attribute type information from the components.
121 * Success: Pointer to a NULL-terminated array that contains the DN
126 * Free the string array with ldap_value_free.
128 WCHAR
** CDECL
ldap_explode_dnW( WCHAR
*dn
, ULONG notypes
)
133 TRACE( "(%s, 0x%08x)\n", debugstr_w(dn
), notypes
);
135 if ((dnU
= strWtoU( dn
)))
137 struct ldap_explode_dn_params params
= { dnU
, notypes
, &retU
};
138 LDAP_CALL( ldap_explode_dn
, ¶ms
);
139 ret
= strarrayUtoW( retU
);
142 LDAP_CALL( ldap_memvfree
, retU
);
147 /***********************************************************************
148 * ldap_get_dnA (WLDAP32.@)
152 char * CDECL
ldap_get_dnA( LDAP
*ld
, LDAPMessage
*entry
)
157 TRACE( "(%p, %p)\n", ld
, entry
);
159 if (!ld
|| !entry
) return NULL
;
161 retW
= ldap_get_dnW( ld
, entry
);
163 ret
= strWtoA( retW
);
164 ldap_memfreeW( retW
);
168 /***********************************************************************
169 * ldap_get_dnW (WLDAP32.@)
171 * Retrieve the DN from a given LDAP message.
174 * ld [I] Pointer to an LDAP context.
175 * entry [I] LDAPMessage structure to retrieve the DN from.
178 * Success: Pointer to a string that contains the DN.
182 * Free the string with ldap_memfree.
184 WCHAR
* CDECL
ldap_get_dnW( LDAP
*ld
, LDAPMessage
*entry
)
189 TRACE( "(%p, %p)\n", ld
, entry
);
193 struct ldap_get_dn_params params
= { CTX(ld
), MSG(entry
), &retU
};
194 LDAP_CALL( ldap_get_dn
, ¶ms
);
196 ret
= strUtoW( retU
);
197 LDAP_CALL( ldap_memfree
, retU
);
202 /***********************************************************************
203 * ldap_ufn2dnA (WLDAP32.@)
207 ULONG CDECL
ldap_ufn2dnA( char *ufn
, char **dn
)
210 WCHAR
*ufnW
= NULL
, *dnW
= NULL
;
212 TRACE( "(%s, %p)\n", debugstr_a(ufn
), dn
);
214 if (!dn
) return LDAP_PARAM_ERROR
;
217 if (ufn
&& !(ufnW
= strAtoW( ufn
))) return LDAP_NO_MEMORY
;
219 ret
= ldap_ufn2dnW( ufnW
, &dnW
);
223 if (!(str
= strWtoA( dnW
))) ret
= LDAP_NO_MEMORY
;
228 ldap_memfreeW( dnW
);
232 /***********************************************************************
233 * ldap_ufn2dnW (WLDAP32.@)
235 * Convert a user-friendly name to a DN.
238 * ufn [I] User-friendly name to convert.
239 * dn [O] Receives a pointer to a string containing the DN.
242 * Success: LDAP_SUCCESS
243 * Failure: An LDAP error code.
246 * Free the string with ldap_memfree.
248 ULONG CDECL
ldap_ufn2dnW( WCHAR
*ufn
, WCHAR
**dn
)
250 ULONG ret
= LDAP_SUCCESS
;
253 TRACE( "(%s, %p)\n", debugstr_w(ufn
), dn
);
255 if (!dn
) return LDAP_PARAM_ERROR
;
261 if (!(ufnU
= strWtoU( ufn
))) return LDAP_NO_MEMORY
;
263 /* FIXME: do more than just a copy */
264 if (!(str
= strUtoW( ufnU
))) ret
= LDAP_NO_MEMORY
;