1

ポート 10389 で実行されている LDAP サーバーに接続するプログラムを作成しています。ユーザー dn とパスワードを使用してサーバーに正常にバインドできます。

これが私のサンプルプログラムです:

#include "windows.h"
#include "winldap.h"
#include "stdio.h"

int main(int argc, char* argv[])
{
    LDAP* pLdapConnection = NULL;
    ULONG version = LDAP_VERSION3;
    ULONG connectSuccess = 0;
    INT returnCode = 0;

    pLdapConnection = ldap_init("localhost", 10389);

    if (pLdapConnection == NULL)
    {
        printf( "ldap_init failed");
        goto error_exit;
    }
    else
        printf("ldap_init succeeded \n");

    //  Set the version to 3.0 (default is 2.0).
    returnCode = ldap_set_option(pLdapConnection,
                                 LDAP_OPT_PROTOCOL_VERSION,
                                 (void*)&version);

    if(returnCode != LDAP_SUCCESS)
    {
        printf("SetOption Error:%0X\n", returnCode);
        goto error_exit;
    }

    // Connect to the server.
    connectSuccess = ldap_connect(pLdapConnection, NULL);

    if(connectSuccess == LDAP_SUCCESS)
        printf("ldap_connect succeeded \n");
    else
    {
        printf("ldap_connect failed with 0x%x.\n",connectSuccess);
        goto error_exit;
    }

    printf("Binding ...\n");

    returnCode = ldap_bind_s(pLdapConnection, "dc=mojo,dc=com", "mojo", LDAP_AUTH_SIMPLE);

    if (returnCode == LDAP_SUCCESS)
        printf("The bind was successful");
    else{
        printf("ldap_bind_s failed with 0x%x.\n",returnCode);
        goto error_exit;
    }

    //  Cleanup and exit.
    ldap_unbind(pLdapConnection);
    return 0;

    //  On error cleanup and exit.
    error_exit:
        ldap_unbind(pLdapConnection);
        return -1;
}

" " 経由で接続するにはどうすればよいldaps://ですか? LDAP サーバーはポート 10636 でリッスンしています。

ここに画像の説明を入力

プログラムがポート 10636 で「ldaps」に接続するには何が必要ですか?

4

1 に答える 1

1

LDAPS は、SSL トンネルを介して LDAP に接続するために使用されるプロトコルです。つまり、SSL セッション (または LDAP のバージョンによっては TLS) を開始し、LDAP プロトコルを使用してサーバーに接続する必要があります。

Windows LDAPS プロトコルは次のとおりです: http://support.microsoft.com/kb/938703

于 2013-05-13T13:12:23.323 に答える