1

OpenLDAP サーバー「クローン」に接続しようとしています。Synapse Library を使用してみましたが、公開連絡先の一部 (約 50%) しか取得できませんでした。

私は今ADOの方法を試しています(ADSIは他のLDAPサーバーと互換性があることを読んだことがあります)が、うまくいきません。

ADOConnection プロバイダーの接続文字列は次のようになります。

Provider=ADsDSOObject;Encrypt Password=False;Integrated Security=SSPI;Data Source=NIS;Mode=Read;Bind Flags=0;ADSI Flag=-2147483648;

ADOConnection.LoginPrompt が true に設定されています。

ADOQuery SQL ステートメントは次のようになります。

Select Description FROM 'LDAP://192.168.xxx.xxx/fn=Public Folders/cn=user@domain.com/fn=ContactRoot' WHERE objectClass='*'

ADOQuery を開くとエラーが発生します (フランス語からの翻訳):「無効なディレクトリ パスが送信されました」

ここで何が問題なのですか? ADO / Synapse以外に無料のソリューションはありますか?

前もって感謝します

SW

4

1 に答える 1

0

COM を使用できます。

  • 以下のユニット(ActiveDs_TLB.pas)を生成します。

次のことができるようになりました。

また

以下を定義します。

function ADsGetObject( lpszPathName: WideString; const riid: TGUID; out ppObject ):HRESULT; stdcall; external 'activeds.dll';

次のようなコードを使用して LDAP オブジェクトを取得できます。

function GetUserNameFromAD( const ADName: string ): string;
var
    Token:              THandle;
    Info, User, Domain: array [ 0..255 ] of Byte;
    ILen, ULen, DLen:   Longword;
    Use:                SID_NAME_USE;
    Usr:                IAdsUser;
begin
    Result := '';
    // Get the thread token. If the current thread is not impersonating, get the process token.
    if not OpenThreadToken( GetCurrentThread(), TOKEN_QUERY, True, Token ) then begin
        if GetLastError() <> ERROR_NO_TOKEN then Exit;
        if not OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, Token ) then Exit;
    end;
    try
        // Get name of domain and username using the token.
        if not GetTokenInformation( Token, TokenUser, @Info, sizeof( Info ), ILen ) then Exit;
        ULen := sizeof( User );
        DLen := sizeof( Domain );
        if not LookupAccountSid( nil, PSIDAndAttributes( @Info )^.Sid, @User, ULen, @Domain, DLen, Use ) then Exit;
        // Should be the specified domain
        if ADName <> PChar( @Domain ) then Exit;
        // Check user and domain with the AD and obtain the username from the AD
        if ADsGetObject( 'WinNT://' + PChar( @Domain ) + '/' + PChar( @User ), IADsUser, Usr ) <> S_OK then Exit;
        if Assigned( Usr ) then Result := Usr.Name;
    finally
        CloseHandle(Token);
    end;
end;

これらの単位の使用方法の例が Web 上にいくつかあります。

于 2010-02-23T22:17:00.720 に答える