开发者

"Network path not found" when using WinNT provider and Delphi to query ADSI

开发者 https://www.devze.com 2023-03-26 20:33 出处:网络
I am querying ADSI using the WINNT provider with code similar to this : var User : IADSUser; begin User := GetObject(\'WinNT://\'+domainname+\'/\'+username + \', user\') as IADSUser;

I am querying ADSI using the WINNT provider with code similar to this :

var
  User : IADSUser;
begin
  User := GetObject('WinNT://'+domainname+'/'+username + ', user') as IADSUser;
  ...
  ...

where GetObject is defined as :

function GetObject (const Name : string): IDispatch;
var
  Moniker : IMoniker;
  Eaten : integer;
  BindContext : IBindCtx;
  Dispatch : IDispatch;
begin
  OleCheck( CreateBindCtx( 0, BindContext ) );
  OleCheck( MkParseDisplayName( BindContext, PWideChar(  WideString( Name ) ), Eaten, Moniker ) );
  OleCheck( Moniker.BindToObject( BindContext, NIL, IDispatch,  Dispatch ) );
  Result := Dispatch;
end;

This has been working for a few years now without problem I have one installation though where on a particular domain, I get a Network Path Not Found error when querying from a different domain. This setup has 4 different domains. There is full trust between the domains, and the query works fine on the offending domain when queried from within the domain. It's just when this is tried from one of the other domains. It is possible to query the domain using a number of other too开发者_Go百科ls, so everything seems ok. Any ideas why this particular domain might be giving this problem?

0

精彩评论

暂无评论...
验证码 换一张
取 消