Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ADSI

Posted on 2000-04-14
2
Medium Priority
?
369 Views
Last Modified: 2010-04-04
How can I get interface IAds with Delphi? In Visual Basic i can use function GetObject, in Visual C++ it's GetADsObject... Can I get it in Delphi??? Help!!!
0
Comment
Question by:donsalvatore
2 Comments
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2715438
I don't know what IAds is, but...

ComExplorer tells me there is an Iads interface in Activeds.dll. I tried to import the type library from the dll with D5, but an error was generated. I then noticed Activeds.TLB in my system dir. I successfully imported the TLB.

I don't know where the TLB came from, or if it's standard distribution. I am running WIN98.

Is this the interface you were looking for?

IADs = interface(IDispatch)
    ['{FD8256D0-FD15-11CE-ABC4-02608C9E7553}']
    function  Get_Name: WideString; safecall;
    function  Get_Class_: WideString; safecall;
    function  Get_GUID: WideString; safecall;
    function  Get_ADsPath: WideString; safecall;
    function  Get_Parent: WideString; safecall;
    function  Get_Schema: WideString; safecall;
    procedure GetInfo; safecall;
    procedure SetInfo; safecall;
    function  Get(const bstrName: WideString): OleVariant; safecall;
    procedure Put(const bstrName: WideString; vProp: OleVariant); safecall;
    function  GetEx(const bstrName: WideString): OleVariant; safecall;
    procedure PutEx(lnControlCode: Integer; const bstrName: WideString; vProp: OleVariant); safecall;
    procedure GetInfoEx(vProperties: OleVariant; lnReserved: Integer); safecall;
    property Name: WideString read Get_Name;
    property Class_: WideString read Get_Class_;
    property GUID: WideString read Get_GUID;
    property ADsPath: WideString read Get_ADsPath;
    property Parent: WideString read Get_Parent;
    property Schema: WideString read Get_Schema;
  end;

After reading the TLB, I guess it's Active Directory Services?

Mark
0
 
LVL 17

Accepted Solution

by:
inthe earned 800 total points
ID: 2717409
interface

function ADsGetObject(lpszPathName: PWideChar; const riid: TIID;   out obj): HResult; stdcall;
function hhGetObject(Id:PWideChar):variant;
function hhGetTopServerId(const w3svc:variant):integer;
function hhMakeWebServer(const w3svc:variant;
                         const IPAddress:string='';
                         const IPPort:integer=80;
                         const Description:string='New Web Site'):variant;
function hhMakeVirtualDirectory(const webserver:variant;
                                const Path:string; //**
                                const HomeDirectory:string; //**
                                const DefaultDocument:string='default.htm'; //**
                                const EnableDefaultDocument:boolean=TRUE;
                                const ReadPermission:boolean=FALSE;
                                const WritePermission:boolean=FALSE;
                                const DirectoryBRowsing:boolean=FALSE;
                                const ExecutePermission:boolean=FALSE):variant;

implementation

function ADsGetObject;  external 'activeds.dll';
function hhGetObject(Id:PWideChar):variant;
begin
  if ADsGetObject(Id, IDispatch, TVarData(result).VDispatch) = S_OK then
    TVarData(result).vType := varDispatch
  else
    Result:= Unassigned;
end;

function hhGetTopServerId(const w3svc:variant):integer;
var
  I:integer;
  ws:variant;
begin
  if not varisempty(w3svc) then
  begin
    Result:=-1;
    i:=0;
    repeat
      try
        inc(i);
        ws:=w3svc.GetObject('IIsWebServer', i);
      except on e:exception do
        Result:=i-1;
      end;
    until Result<>-1;
  end
  else
    Result:=-1;
end;

function hhMakeWebServer(const w3svc:variant;
                         const IPAddress:string='';
                         const IPPort:integer=80;
                         const Description:string='New Web Site'):variant;
var
  NewId:integer;
begin
  if not VarIsEmpty(w3svc) then
  begin
    NewId:=hhGetTopServerId(w3svc)+1;
    result:=w3svc.Create('IIsWebServer',NewId);
    result.ServerComment:=Description;
    result.ServerBindings:=VarArrayOf([IPADdress+':'+inttostr(IPPort)+':']);
    result.Keytype:='IIsWebServer';
    result.setinfo;
  end
  else
    result := Unassigned;
end;

function hhMakeVirtualDirectory(const webserver:variant;
                                const Path:string; //**
                                const HomeDirectory:string; //**
                                const DefaultDocument:string='default.htm'; //**
                                const EnableDefaultDocument:boolean=TRUE;
                                const ReadPermission:boolean=FALSE;
                                const WritePermission:boolean=FALSE;
                                const DirectoryBRowsing:boolean=FALSE;
                                const ExecutePermission:boolean=FALSE):variant;
begin
  if not VarIsEmpty(WebServer) then
  begin
    Result:=WebServer.Create('IIsWebVirtualDir',Path);
    Result.Path := HomeDirectory;
    Result.DefaultDoc := DefaultDocument;
    Result.EnableDefaultDoc := EnableDefaultDocument;
    Result.EnableDirBrowsing := DirectoryBrowsing;
    Result.AccessExecute := ExecutePermission;
    Result.AccessRead := ReadPermission;
    Result.AccessWrite := WritePermission;
    Result.AccessSource := FALSE;
    Result.SetInfo;
  end
  else
    Result:=UnAssigned;
end;



-- EXAMPLE CALLS --
var
  w3svc,WebServer,RootDir,ScriptDir:variant;
begin
  w3svc:=hhGetObject('IIS://LocalHost/W3SVC');
  if not VarIsEmpty(w3svc) then
  begin
    WebServer:=hhMakeWebServer(w3svc,'192.168.10.1',80,'Web Web Site');
    RootDir:=hhMakeVirtualDirectory(WebServer,'ROOT','C:\INETPUB\WWW','index.html',TRUE,TRUE,FALSE,FALSE,FALSE);
    ScriptDir:=hhMakeVirtualDirectory(RootDir,'Scripts','C:\INETPUB\IMAGES','',FALSE,FALSE,FALSE,FALSE,TRUE);
    WebServer.Start;
  end
  else
    ShowMEssage('Failed');
end;


with thanks to crazner
-- USEFUL URL --

MSDN Documentation on IIS ADSI ..
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/iisref/adsi57hv.htm


Regards Barry
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question