最近,我接手了一些Delphi法典(这是Delphi5,但我认为这很重要),这些守则使用LDAP提出了问题。 该法典非常令人困惑,因为它既包括连接,又直接设定了财产。 有一个安装方案,其中含有一些自动处理参数。 守则中哪些部分是相关的,哪些部分可以削减? 如果安装方案存在不必要的问题,我特别感兴趣。
- Is it possible to simplify the code? (i.e. does ConnectionString (or any of the containing parameters) have any use in this code?)
- Are
Data Source
(given as ADserver in installation program) orLocation
(given as ADlocation in installation program) used in call to Open or Execute?
我试图删除<条码>aADOlinkion.provider:= ADsDSOObject ; 或“联系标准”,以及电话工作。 删除<> 该呼吁当然失败了。 该法典是用来检查反倾销连接的,在为用户询问这些团体时,也存在类似的(但更长的)密码区。
Connecstr_S:= Provider=ADsDSOObject;Encrypt Password=False;Data Source= +
Tsystem.programsettings.sADserver+ ;Location= +
Tsystem.programsettings.sADlocation+ ;Mode=Read;Bind Flags=0;ADSI Flag=-2147483648 ;
aADOconnection:=TADOConnection.create(nil);
aADOcmd:=TADOCommand.create(nil);
aADOconnection.loginprompt:=false;
aADOconnection.commandtimeout:=30;
aADOconnection.connectoptions:=coConnectUnspecified;
aADOconnection.CursorLocation:=cluseclient;
aADOconnection.isolationlevel:=ilCursorStability;
aADOconnection.mode:=cmunknown;
aADOconnection.provider:= ADsDSOObject ;
aADOcmd.commandtype:=cmdUnknown;
aADOcmd.Paramcheck:=false;
aADOcmd.commandtimeout:=30;
aADOcmd.Prepared:=false;
aADOconnection.ConnectionString:=Connecstr_S;
aADOcmd.Connection:=aADOconnection;
aADOconnection.open;
result:=true;
try
SQL:= select displayname from +quotedstr( LDAP:// +Tsystem.programsettings.sADbaseDN)+
where +Tsystem.programsettings.sADuseridAttribute+ = +quotedstr( aaaaaaa );
aADOcmd.CommandText:=SQL;
t:=aADOcmd.Execute;
except
On E:EOleException do result:=false; //network connection probably missing
end;
aADOconnection.close;
aADOcmd.free;
aADOconnection.free;