Comment utiliser ADSOpenObject dans une DLL ?

Dans une application, ça fonctionne bien, mais dans une DLL, ça échoue à chaque fois (ça renvoit faux, comme si le login/mdp était incorrect).

Code dans la DLL :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
   function ADsOpenObject(lpszPathName: PWideChar; lpszUserName: PWideChar; lpszPassword: PWideChar; dwReserved: LongInt; const riid: TGUID; out obj): HResult;   stdcall;   external 'activeds.dll';
 
function VerificationMDPLDAP(const szLogin, szPwd: String): Boolean;
var
   wUsername, wPassword: WideString;
//   OutObj: Pointer;
   UnknownObj: IUnknown;
   HR: HResult;
begin
   wUsername := szLogin;
   wPassword := szPwd;
   HR := ADSOpenObject('LDAP://serveurdomaine/DC=domaine,DC=LOC', PWideChar(wUsername), PWideChar(wPassword), ADS_SECURE_AUTHENTICATION, IID_IADs, UnknownObj);
   if HR = S_OK then
      Result := True
   else
      Result := False;
end;
Y-a-t'il des précautions ou des choses à faire attention ?