📄 ldapauthlib.pas.~9~
字号:
unit ldapauthlib;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ldapclasses, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
LDAPSession:TLDAPSession;
LDAPEntryList:TLDAPEntryList;
SearchCallBack:TSearchCallback;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var e:array[0..0] of string;
i:integer;
begin
LDAPSession := TLDAPSession.Create;
LDAPEntryList := TLDAPEntryList.create;
LDAPSession.Server := '192.168.2.10';
LDAPSession.Base := 'dc=ad,dc=freemeg,dc=com';
LDAPSESSION.PagedSearch := TRUE;
LDAPSEssion.PageSize := 100;
LDAPSession.SSL := false;
LDAPSession.DereferenceAliases := 0;
LDAPSession.Version := 3;
LDAPSEssion.AuthMethod := 0;
// LDAPSession.User := 'cn=administrator,dc=ad,dc=freemeg,dc=com';
LDAPSession.User := 'administrator@ad.freemeg.com';
LDAPSession.Password := 'solfi25/3';
LdapSession.ChaseReferrals := true;
ldapsession.ReferralHops := 32;
LDAPSession.Connect;
showmessage('here');
e[0] := 'uid';
if ldapsession.Connected then
begin
memo1.Lines.add('Connected');
LDAPSession.Search('uid=jake','dc=ad,dc=freemeg,dc=com',2,e,FALSE,LdapENtrylist, SearchCallBack);
if ldapentrylist.Count > 0 then
begin
LDAPSession.Disconnect;
try
memo1.Lines.Add(ldapentrylist.Items[0].dn);
LDAPSession.User := LDAPEntrylist.Items[0].dn;
LDAPSession.Password := 'bljag';
LDAPSession.Connect;
if LDAPSession.connected then
begin
memo1.lines.add('Yes');
end;
except
on e:exception do
SHowmessage('Sorry Bad something');
end;
end;
end
else memo1.lines.add('Failed to Connect');
// LDAPSession.Search('','dc=freemeg.com',0,'uid',0,LdapEntryList,SearchCallBack);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -