D2009 compatibility fix

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@99 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2009-09-29 10:42:05 +00:00
parent 71b081e456
commit b6ad738531

View File

@ -1,9 +1,9 @@
{==============================================================================|
| Project : Ararat Synapse | 001.005.000 |
| Project : Ararat Synapse | 001.006.000 |
|==============================================================================|
| Content: LDAP client |
|==============================================================================|
| Copyright (c)1999-2008, Lukas Gebauer |
| Copyright (c)1999-2009, Lukas Gebauer |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2003-2005. |
| Portions created by Lukas Gebauer are Copyright (c)2003-2009. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
@ -92,15 +92,15 @@ type
descendant of TStringList class enhanced by some new properties.}
TLDAPAttribute = class(TStringList)
private
FAttributeName: string;
FAttributeName: AnsiString;
FIsBinary: Boolean;
protected
function Get(Index: integer): string; override;
procedure Put(Index: integer; const Value: string); override;
procedure SetAttributeName(Value: string);
procedure SetAttributeName(Value: AnsiString);
published
{:Name of LDAP attribute.}
property AttributeName: string read FAttributeName Write SetAttributeName;
property AttributeName: AnsiString read FAttributeName Write SetAttributeName;
{:Return @true when attribute contains binary data.}
property IsBinary: Boolean read FIsBinary;
end;
@ -123,7 +123,7 @@ type
{:Delete one TLDAPAttribute object from list.}
procedure Del(Index: integer);
{:Find and return attribute with requested name. Returns nil if not found.}
function Find(AttributeName: string): TLDAPAttribute;
function Find(AttributeName: AnsiString): TLDAPAttribute;
{:List of TLDAPAttribute objects.}
property Items[Index: Integer]: TLDAPAttribute read GetAttribute; default;
end;
@ -133,14 +133,14 @@ type
values)}
TLDAPResult = class(TObject)
private
FObjectName: string;
FObjectName: AnsiString;
FAttributes: TLDAPAttributeList;
public
constructor Create;
destructor Destroy; override;
published
{:Name of this LDAP object.}
property ObjectName: string read FObjectName write FObjectName;
property ObjectName: AnsiString read FObjectName write FObjectName;
{:Here is list of object attributes.}
property Attributes: TLDAPAttributeList read FAttributes;
end;
@ -198,13 +198,13 @@ type
private
FSock: TTCPBlockSocket;
FResultCode: Integer;
FResultString: string;
FFullResult: string;
FResultString: AnsiString;
FFullResult: AnsiString;
FAutoTLS: Boolean;
FFullSSL: Boolean;
FSeq: integer;
FResponseCode: integer;
FResponseDN: string;
FResponseDN: AnsiString;
FReferals: TStringList;
FVersion: integer;
FSearchScope: TLDAPSearchScope;
@ -212,15 +212,15 @@ type
FSearchSizeLimit: integer;
FSearchTimeLimit: integer;
FSearchResult: TLDAPResultList;
FExtName: string;
FExtValue: string;
FExtName: AnsiString;
FExtValue: AnsiString;
function Connect: Boolean;
function BuildPacket(const Value: string): string;
function ReceiveResponse: string;
function DecodeResponse(const Value: string): string;
function LdapSasl(Value: string): string;
function TranslateFilter(Value: string): string;
function GetErrorString(Value: integer): string;
function BuildPacket(const Value: AnsiString): AnsiString;
function ReceiveResponse: AnsiString;
function DecodeResponse(const Value: AnsiString): AnsiString;
function LdapSasl(Value: AnsiString): AnsiString;
function TranslateFilter(Value: AnsiString): AnsiString;
function GetErrorString(Value: integer): AnsiString;
public
constructor Create;
destructor Destroy; override;
@ -249,26 +249,26 @@ type
function Logout: Boolean;
{:Modify content of LDAP attribute on this object.}
function Modify(obj: string; Op: TLDAPModifyOp; const Value: TLDAPAttribute): Boolean;
function Modify(obj: AnsiString; Op: TLDAPModifyOp; const Value: TLDAPAttribute): Boolean;
{:Add list of attributes to specified object.}
function Add(obj: string; const Value: TLDAPAttributeList): Boolean;
function Add(obj: AnsiString; const Value: TLDAPAttributeList): Boolean;
{:Delete this LDAP object from server.}
function Delete(obj: string): Boolean;
function Delete(obj: AnsiString): Boolean;
{:Modify object name of this LDAP object.}
function ModifyDN(obj, newRDN, newSuperior: string; DeleteoldRDN: Boolean): Boolean;
function ModifyDN(obj, newRDN, newSuperior: AnsiString; DeleteoldRDN: Boolean): Boolean;
{:Try to compare Attribute value with this LDAP object.}
function Compare(obj, AttributeValue: string): Boolean;
function Compare(obj, AttributeValue: AnsiString): Boolean;
{:Search LDAP base for LDAP objects by Filter.}
function Search(obj: string; TypesOnly: Boolean; Filter: string;
function Search(obj: AnsiString; TypesOnly: Boolean; Filter: AnsiString;
const Attributes: TStrings): Boolean;
{:Call any LDAPv3 extended command.}
function Extended(const Name, Value: string): Boolean;
function Extended(const Name, Value: AnsiString): Boolean;
{:Try to start SSL/TLS connection to LDAP server.}
function StartTLS: Boolean;
@ -280,11 +280,11 @@ type
property ResultCode: Integer read FResultCode;
{:Human readable description of result code of last LDAP operation.}
property ResultString: string read FResultString;
property ResultString: AnsiString read FResultString;
{:Binary string with full last response of LDAP server. This string is
encoded by ASN.1 BER encoding! You need this only for debugging.}
property FullResult: string read FFullResult;
property FullResult: AnsiString read FFullResult;
{:If @true, then try to start TSL mode in Login procedure.}
property AutoTLS: Boolean read FAutoTLS Write FAutoTLS;
@ -317,18 +317,18 @@ type
{:When you call @link(Extended) operation, then here is result Name returned
by server.}
property ExtName: string read FExtName;
property ExtName: AnsiString read FExtName;
{:When you call @link(Extended) operation, then here is result Value returned
by server.}
property ExtValue: string read FExtValue;
property ExtValue: AnsiString read FExtValue;
{:TCP socket used by all LDAP operations.}
property Sock: TTCPBlockSocket read FSock;
end;
{:Dump result of LDAP SEARCH into human readable form. Good for debugging.}
function LDAPResultDump(const Value: TLDAPResultList): string;
function LDAPResultDump(const Value: TLDAPResultList): AnsiString;
implementation
@ -342,7 +342,7 @@ end;
procedure TLDAPAttribute.Put(Index: integer; const Value: string);
var
s: string;
s: AnsiString;
begin
s := Value;
if FIsbinary then
@ -352,7 +352,7 @@ begin
inherited Put(Index, s);
end;
procedure TLDAPAttribute.SetAttributeName(Value: string);
procedure TLDAPAttribute.SetAttributeName(Value: AnsiString);
begin
FAttributeName := Value;
FIsBinary := Pos(';binary', Lowercase(value)) > 0;
@ -414,7 +414,7 @@ begin
FAttributeList.Delete(Index);
end;
function TLDAPAttributeList.Find(AttributeName: string): TLDAPAttribute;
function TLDAPAttributeList.Find(AttributeName: AnsiString): TLDAPAttribute;
var
n: integer;
x: TLDAPAttribute;
@ -520,7 +520,7 @@ begin
inherited Destroy;
end;
function TLDAPSend.GetErrorString(Value: integer): string;
function TLDAPSend.GetErrorString(Value: integer): AnsiString;
begin
case Value of
0:
@ -623,13 +623,13 @@ begin
Result := FSock.LastError = 0;
end;
function TLDAPSend.BuildPacket(const Value: string): string;
function TLDAPSend.BuildPacket(const Value: AnsiString): AnsiString;
begin
Inc(FSeq);
Result := ASNObject(ASNObject(ASNEncInt(FSeq), ASN1_INT) + Value, ASN1_SEQ);
end;
function TLDAPSend.ReceiveResponse: string;
function TLDAPSend.ReceiveResponse: AnsiString;
var
x: Byte;
i,j: integer;
@ -639,9 +639,9 @@ begin
x := FSock.RecvByte(FTimeout);
if x <> ASN1_SEQ then
Exit;
Result := Char(x);
Result := AnsiChar(x);
x := FSock.RecvByte(FTimeout);
Result := Result + Char(x);
Result := Result + AnsiChar(x);
if x < $80 then
i := 0
else
@ -667,11 +667,11 @@ begin
FFullResult := Result;
end;
function TLDAPSend.DecodeResponse(const Value: string): string;
function TLDAPSend.DecodeResponse(const Value: AnsiString): AnsiString;
var
i, x: integer;
Svt: Integer;
s, t: string;
s, t: AnsiString;
begin
Result := '';
FResultCode := -1;
@ -713,11 +713,11 @@ begin
Result := Copy(Value, i, Length(Value) - i + 1);
end;
function TLDAPSend.LdapSasl(Value: string): string;
function TLDAPSend.LdapSasl(Value: AnsiString): AnsiString;
var
nonce, cnonce, nc, realm, qop, uri, response: string;
s: string;
a1, a2: string;
nonce, cnonce, nc, realm, qop, uri, response: AnsiString;
s: AnsiString;
a1, a2: AnsiString;
l: TStringList;
n: integer;
begin
@ -751,12 +751,13 @@ begin
end;
end;
function TLDAPSend.TranslateFilter(Value: string): string;
function TLDAPSend.TranslateFilter(Value: AnsiString): AnsiString;
var
x: integer;
s, t, l, r: string;
c: char;
attr, rule: string;
s, t, l: AnsiString;
r: string;
c: Ansichar;
attr, rule: AnsiString;
dn: Boolean;
begin
Result := '';
@ -910,7 +911,7 @@ end;
function TLDAPSend.Bind: Boolean;
var
s: string;
s: AnsiString;
begin
s := ASNObject(ASNEncInt(FVersion), ASN1_INT)
+ ASNObject(FUsername, ASN1_OCTSTR)
@ -924,9 +925,9 @@ end;
function TLDAPSend.BindSasl: Boolean;
var
s, t: string;
s, t: AnsiString;
x, xt: integer;
digreq: string;
digreq: AnsiString;
begin
Result := False;
if FPassword = '' then
@ -971,9 +972,9 @@ begin
Result := True;
end;
function TLDAPSend.Modify(obj: string; Op: TLDAPModifyOp; const Value: TLDAPAttribute): Boolean;
function TLDAPSend.Modify(obj: AnsiString; Op: TLDAPModifyOp; const Value: TLDAPAttribute): Boolean;
var
s: string;
s: AnsiString;
n: integer;
begin
s := '';
@ -990,9 +991,9 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.Add(obj: string; const Value: TLDAPAttributeList): Boolean;
function TLDAPSend.Add(obj: AnsiString; const Value: TLDAPAttributeList): Boolean;
var
s, t: string;
s, t: AnsiString;
n, m: integer;
begin
s := '';
@ -1013,9 +1014,9 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.Delete(obj: string): Boolean;
function TLDAPSend.Delete(obj: AnsiString): Boolean;
var
s: string;
s: AnsiString;
begin
s := ASNObject(obj, LDAP_ASN1_DEL_REQUEST);
Fsock.SendString(BuildPacket(s));
@ -1024,9 +1025,9 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.ModifyDN(obj, newRDN, newSuperior: string; DeleteOldRDN: Boolean): Boolean;
function TLDAPSend.ModifyDN(obj, newRDN, newSuperior: AnsiString; DeleteOldRDN: Boolean): Boolean;
var
s: string;
s: AnsiString;
begin
s := ASNObject(obj, ASN1_OCTSTR) + ASNObject(newRDN, ASN1_OCTSTR);
if DeleteOldRDN then
@ -1042,9 +1043,9 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.Compare(obj, AttributeValue: string): Boolean;
function TLDAPSend.Compare(obj, AttributeValue: AnsiString): Boolean;
var
s: string;
s: AnsiString;
begin
s := ASNObject(Trim(SeparateLeft(AttributeValue, '=')), ASN1_OCTSTR)
+ ASNObject(Trim(SeparateRight(AttributeValue, '=')), ASN1_OCTSTR);
@ -1056,10 +1057,10 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.Search(obj: string; TypesOnly: Boolean; Filter: string;
function TLDAPSend.Search(obj: AnsiString; TypesOnly: Boolean; Filter: AnsiString;
const Attributes: TStrings): Boolean;
var
s, t, u: string;
s, t, u: AnsiString;
n, i, x: integer;
r: TLDAPResult;
a: TLDAPAttribute;
@ -1130,9 +1131,9 @@ begin
Result := FResultCode = 0;
end;
function TLDAPSend.Extended(const Name, Value: string): Boolean;
function TLDAPSend.Extended(const Name, Value: AnsiString): Boolean;
var
s, t: string;
s, t: AnsiString;
x, xt: integer;
begin
s := ASNObject(Name, $80);
@ -1163,7 +1164,7 @@ begin
end;
{==============================================================================}
function LDAPResultDump(const Value: TLDAPResultList): string;
function LDAPResultDump(const Value: TLDAPResultList): AnsiString;
var
n, m, o: integer;
r: TLDAPResult;