unit main;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, Data.DB, Data.Win.ADODB,
Vcl.StdCtrls,
Vcl.Grids,
Vcl.DBGrids;
type
TForm5 =
class(TForm)
con_AD: TADOConnection;
Button1: TButton;
DBGrid1: TDBGrid;
Button2: TButton;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADOQuery2: TADOQuery;
DataSource2: TDataSource;
procedure Button1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
begin
con_AD.Close;
Con_AD.ConnectionString := '
Provider=ADsDSOObject;User ID=XXXXXX;Password=XXXXX;Encrypt Password=True;Mode=Read';
//;Bind Flags=0;ADSI Flag=-2147483648';
con_AD.LoginPrompt := False;
con_AD.Open;
{
ADOConnection1.ConnectionString := 'Provider=sqloledb;' +
'Data Source=XXXX;'+
'Initial Catalog=XXXXXX;'+
'User Id=XXXX;' +
'Password=XXXXX';
ADOConnection1.LoginPrompt := False;
ADOConnection1.Open;
}
end;
procedure TForm5.Button2Click(Sender: TObject);
var
sql_str :
string;
domain :
string;
begin
SQL_str := '
select AdsPath, CN, SN from ' + quotedstr('
LDAP://DC=XXXXX,DC=XX') + '
where objectclass=' + quotedstr('
user') + '
ORDER by sn';
//ShowMessage(sql_str);
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sql_str);
try
ADOQuery1.Active := true;
except
on e :
Exception Do showmessage(e.
Message);
end;
{ SQL_str := 'select * from dateien';
ADOQuery2.Active := false;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add(sql_str);
try
ADOQuery2.Active := true;
except
on e : Exception Do showmessage(e.Message);
end;
}
end;
procedure TForm5.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
ADOQuery1.Active := false;
con_AD.Close;
end;
end.