📄 init.c
字号:
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_initW (WLDAP32.@)
*
* Initialize an LDAP context and create a TCP connection.
*
* PARAMS
* hostname [I] Name of the host to connect to.
* portnumber [I] Portnumber to use.
*
* RETURNS
* Success: Pointer to an LDAP context.
* Failure: NULL
*
* NOTES
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
* trailing portnumber (separated from the hostname by a ':'), which
* will take precedence over the portnumber supplied as a parameter
* to this function. The connection will not be made until the first
* LDAP function that needs it is called.
*/
WLDAP32_LDAP * CDECL ldap_initW( PWCHAR hostname, ULONG portnumber )
{
#ifdef HAVE_LDAP
LDAP *ld = NULL;
char *hostnameU = NULL, *url = NULL;
TRACE( "(%s, %d)\n", debugstr_w(hostname), portnumber );
if (hostname) {
hostnameU = strWtoU( hostname );
if (!hostnameU) goto exit;
}
else {
hostnameU = strWtoU( defaulthost );
if (!hostnameU) goto exit;
}
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
ldap_initialize( &ld, url );
exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_openA (WLDAP32.@)
*
* See ldap_openW.
*/
WLDAP32_LDAP * CDECL ldap_openA( PCHAR hostname, ULONG portnumber )
{
#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d)\n", debugstr_a(hostname), portnumber );
if (hostname) {
hostnameW = strAtoW( hostname );
if (!hostnameW) goto exit;
}
ld = ldap_openW( hostnameW, portnumber );
exit:
strfreeW( hostnameW );
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_openW (WLDAP32.@)
*
* Initialize an LDAP context and create a TCP connection.
*
* PARAMS
* hostname [I] Name of the host to connect to.
* portnumber [I] Portnumber to use.
*
* RETURNS
* Success: Pointer to an LDAP context.
* Failure: NULL
*
* NOTES
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
* trailing portnumber (separated from the hostname by a ':'), which
* will take precedence over the portnumber supplied as a parameter
* to this function.
*/
WLDAP32_LDAP * CDECL ldap_openW( PWCHAR hostname, ULONG portnumber )
{
#ifdef HAVE_LDAP
LDAP *ld = NULL;
char *hostnameU = NULL, *url = NULL;
TRACE( "(%s, %d)\n", debugstr_w(hostname), portnumber );
if (hostname) {
hostnameU = strWtoU( hostname );
if (!hostnameU) goto exit;
}
else {
hostnameU = strWtoU( defaulthost );
if (!hostnameU) goto exit;
}
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
ldap_initialize( &ld, url );
exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_sslinitA (WLDAP32.@)
*
* See ldap_sslinitW.
*/
WLDAP32_LDAP * CDECL ldap_sslinitA( PCHAR hostname, ULONG portnumber, int secure )
{
#ifdef HAVE_LDAP
WLDAP32_LDAP *ld;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d, 0x%08x)\n", debugstr_a(hostname), portnumber, secure );
if (hostname) {
hostnameW = strAtoW( hostname );
if (!hostnameW) return NULL;
}
ld = ldap_sslinitW( hostnameW, portnumber, secure );
strfreeW( hostnameW );
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_sslinitW (WLDAP32.@)
*
* Initialize an LDAP context and create a secure TCP connection.
*
* PARAMS
* hostname [I] Name of the host to connect to.
* portnumber [I] Portnumber to use.
* secure [I] Ask the server to create an SSL connection.
*
* RETURNS
* Success: Pointer to an LDAP context.
* Failure: NULL
*
* NOTES
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
* trailing portnumber (separated from the hostname by a ':'), which
* will take precedence over the portnumber supplied as a parameter
* to this function. The connection will not be made until the first
* LDAP function that needs it is called.
*/
WLDAP32_LDAP * CDECL ldap_sslinitW( PWCHAR hostname, ULONG portnumber, int secure )
{
#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
char *hostnameU = NULL, *url = NULL;
TRACE( "(%s, %d, 0x%08x)\n", debugstr_w(hostname), portnumber, secure );
if (hostname) {
hostnameU = strWtoU( hostname );
if (!hostnameU) goto exit;
}
else {
hostnameU = strWtoU( defaulthost );
if (!hostnameU) goto exit;
}
if (secure)
url = urlify_hostnames( "ldaps://", hostnameU, portnumber );
else
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
ldap_initialize( &ld, url );
exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_start_tls_sA (WLDAP32.@)
*
* See ldap_start_tls_sW.
*/
ULONG CDECL ldap_start_tls_sA( WLDAP32_LDAP *ld, PULONG retval, WLDAP32_LDAPMessage **result,
PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %p, %p, %p, %p)\n", ld, retval, result, serverctrls, clientctrls );
if (!ld) return ~0UL;
if (serverctrls) {
serverctrlsW = controlarrayAtoW( serverctrls );
if (!serverctrlsW) goto exit;
}
if (clientctrls) {
clientctrlsW = controlarrayAtoW( clientctrls );
if (!clientctrlsW) goto exit;
}
ret = ldap_start_tls_sW( ld, retval, result, serverctrlsW, clientctrlsW );
exit:
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
#endif
return ret;
}
/***********************************************************************
* ldap_start_tls_s (WLDAP32.@)
*
* Start TLS encryption on an LDAP connection.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* retval [I] Return value from the server.
* result [I] Response message from the server.
* serverctrls [I] Array of LDAP server controls.
* clientctrls [I] Array of LDAP client controls.
*
* RETURNS
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*
* NOTES
* LDAP function that needs it is called.
*/
ULONG CDECL ldap_start_tls_sW( WLDAP32_LDAP *ld, PULONG retval, WLDAP32_LDAPMessage **result,
PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %p, %p, %p, %p)\n", ld, retval, result, serverctrls, clientctrls );
if (!ld) return ~0UL;
if (serverctrls) {
serverctrlsU = controlarrayWtoU( serverctrls );
if (!serverctrlsU) goto exit;
}
if (clientctrls) {
clientctrlsU = controlarrayWtoU( clientctrls );
if (!clientctrlsU) goto exit;
}
ret = ldap_start_tls_s( ld, serverctrlsU, clientctrlsU );
exit:
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
#endif
return ret;
}
/***********************************************************************
* ldap_startup (WLDAP32.@)
*/
ULONG CDECL ldap_startup( PLDAP_VERSION_INFO version, HANDLE *instance )
{
TRACE( "(%p, %p)\n", version, instance );
return LDAP_SUCCESS;
}
/***********************************************************************
* ldap_stop_tls_s (WLDAP32.@)
*
* Stop TLS encryption on an LDAP connection.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOLEAN CDECL ldap_stop_tls_s( WLDAP32_LDAP *ld )
{
TRACE( "(%p)\n", ld );
return TRUE; /* FIXME: find a way to stop tls on a connection */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -