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
26 #include "wine/debug.h"
27 #include "winldap_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
31 /***********************************************************************
32 * ldap_dn2ufnA (WLDAP32.@)
34 char * CDECL
ldap_dn2ufnA( char *dn
)
39 TRACE( "(%s)\n", debugstr_a(dn
) );
41 if (!(dnW
= strAtoW( dn
))) return NULL
;
42 if ((retW
= ldap_dn2ufnW( dnW
))) ret
= strWtoA( retW
);
44 ldap_memfreeW( retW
);
48 /***********************************************************************
49 * ldap_dn2ufnW (WLDAP32.@)
51 WCHAR
* CDECL
ldap_dn2ufnW( WCHAR
*dn
)
56 TRACE( "(%s)\n", debugstr_w(dn
) );
58 if (!(dnU
= strWtoU( dn
))) return NULL
;
59 if ((retU
= ldap_dn2ufn( dnU
))) ret
= strUtoW( retU
);
65 /***********************************************************************
66 * ldap_explode_dnA (WLDAP32.@)
68 char ** CDECL
ldap_explode_dnA( char *dn
, ULONG notypes
)
73 TRACE( "(%s, %#lx)\n", debugstr_a(dn
), notypes
);
75 if (!(dnW
= strAtoW( dn
))) return NULL
;
76 if ((retW
= ldap_explode_dnW( dnW
, notypes
))) ret
= strarrayWtoA( retW
);
78 ldap_value_freeW( retW
);
82 /***********************************************************************
83 * ldap_explode_dnW (WLDAP32.@)
85 WCHAR
** CDECL
ldap_explode_dnW( WCHAR
*dn
, ULONG notypes
)
90 TRACE( "(%s, %#lx)\n", debugstr_w(dn
), notypes
);
92 if (!(dnU
= strWtoU( dn
))) return NULL
;
93 if ((retU
= ldap_explode_dn( dnU
, notypes
))) ret
= strarrayUtoW( retU
);
95 ldap_memvfree( (void **)retU
);
99 /***********************************************************************
100 * ldap_get_dnA (WLDAP32.@)
102 char * CDECL
ldap_get_dnA( LDAP
*ld
, LDAPMessage
*entry
)
107 TRACE( "(%p, %p)\n", ld
, entry
);
109 if (!ld
|| !entry
) return NULL
;
111 if ((retW
= ldap_get_dnW( ld
, entry
))) ret
= strWtoA( retW
);
112 ldap_memfreeW( retW
);
116 /***********************************************************************
117 * ldap_get_dnW (WLDAP32.@)
119 WCHAR
* CDECL
ldap_get_dnW( LDAP
*ld
, LDAPMessage
*entry
)
124 TRACE( "(%p, %p)\n", ld
, entry
);
128 if ((retU
= ldap_get_dn( CTX(ld
), MSG(entry
) ))) ret
= strUtoW( retU
);
129 ldap_memfree( retU
);
134 /***********************************************************************
135 * ldap_ufn2dnA (WLDAP32.@)
137 ULONG CDECL
ldap_ufn2dnA( char *ufn
, char **dn
)
140 WCHAR
*ufnW
= NULL
, *dnW
= NULL
;
142 TRACE( "(%s, %p)\n", debugstr_a(ufn
), dn
);
144 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
147 if (ufn
&& !(ufnW
= strAtoW( ufn
))) return WLDAP32_LDAP_NO_MEMORY
;
149 ret
= ldap_ufn2dnW( ufnW
, &dnW
);
153 if (!(str
= strWtoA( dnW
))) ret
= WLDAP32_LDAP_NO_MEMORY
;
158 ldap_memfreeW( dnW
);
162 /***********************************************************************
163 * ldap_ufn2dnW (WLDAP32.@)
165 ULONG CDECL
ldap_ufn2dnW( WCHAR
*ufn
, WCHAR
**dn
)
167 ULONG ret
= WLDAP32_LDAP_SUCCESS
;
170 TRACE( "(%s, %p)\n", debugstr_w(ufn
), dn
);
172 if (!dn
) return WLDAP32_LDAP_PARAM_ERROR
;
178 if (!(ufnU
= strWtoU( ufn
))) return WLDAP32_LDAP_NO_MEMORY
;
180 /* FIXME: do more than just a copy */
181 if (!(str
= strUtoW( ufnU
))) ret
= WLDAP32_LDAP_NO_MEMORY
;