![]() |
Umstellung LDAP auf SSL/TLS
Ich versuche eine vorhandene Anwendung von LDAP zu LDAPS umzustellen.
Derzeitiges Problem: Fehlermeldung bei der Abfrage der Option LDAP_OPT_SSL. Als Ergebnis bekomme ich einen Code der mit ldap_err2string als "Parameterfehler" zurück gibt.
Delphi-Quellcode:
Das Protokoll:
FConn: Pointer;
FSSL: Pointer; FVersion: Integer; TriggerProtocol(Self, 'Initialize an LDAP session using SSL'); fConn := ldap_sslinit(PChar(fHost), fPort, 1); try FVersion := LDAP_VERSION3; TriggerProtocol(Self, Format('Setting Protocol version to %d', [FVersion])); LDAPCheck(ldap_set_option(fConn, LDAP_OPT_PROTOCOL_VERSION, @FVersion)); TriggerProtocol(Self, 'Checking if SSL is enabled'); FSSL := LDAP_OPT_OFF; LDAPCheck(ldap_get_option(fConn, LDAP_OPT_SSL, FSSL)); TriggerProtocol(Self, IfThen(FSSL = LDAP_OPT_ON, 'SSL is enabled', 'SSL not enabled')); if FSSL <> LDAP_OPT_ON then begin TriggerProtocol(Self, 'SSL being enabled...'); FSSL := LDAP_OPT_ON; LDAPCheck(ldap_set_option(fConn, LDAP_OPT_SSL, FSSL)); end;
Code:
Initialize an LDAP session using SSL
Setting Protocol version to 3 Checking if SSL is enabled Parameterfehler |
AW: Umstellung LDAP auf SSL/TLS
Zitat:
|
AW: Umstellung LDAP auf SSL/TLS
@FSSL
Das gibt "Lokaler Fehler". |
AW: Umstellung LDAP auf SSL/TLS
Zitat:
![]() |
AW: Umstellung LDAP auf SSL/TLS
|
AW: Umstellung LDAP auf SSL/TLS
Zitat:
Code:
Und genau an der Stelle komme ich jetzt nicht weiter.
// Verify that SSL is enabled on the connection.
// (returns LDAP_OPT_ON/_OFF). printf("Checking if SSL is enabled\n"); returnCode = ldap_get_option(pLdapConnection,LDAP_OPT_SSL,(void*)&lv); if (returnCode != LDAP_SUCCESS) goto FatalExit; |
AW: Umstellung LDAP auf SSL/TLS
Well i hastily tried this
Code:
and it did gave me this result in the memo
procedure TForm10.LDAPConnect;
var pConn: PLDAP; Version: NativeUInt; CurrVer: NativeUInt; begin pConn := ldap_sslinit('DESKTOP-HOST1', LDAP_SSL_PORT, 1); if not Assigned(pConn) then Exit; try Version := LDAP_VERSION3; if ldap_set_option(pConn, LDAP_OPT_PROTOCOL_VERSION, @Version) <> LDAP_SUCCESS then Exit; if ldap_get_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; Memo1.Lines.Add('Current SSL status : ' + BoolToStr(CurrVer <> 0, true)); if CurrVer = NativeUInt(LDAP_OPT_OFF) then begin CurrVer := NativeUInt(LDAP_OPT_ON); if ldap_set_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; end; // check again if ldap_get_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; Memo1.Lines.Add('Current SSL status : ' + BoolToStr(CurrVer <> 0, true)); Memo1.Lines.Add('Success'); finally ldap_unbind_s(pConn); end; end; Zitat:
There is no Error at all ! |
AW: Umstellung LDAP auf SSL/TLS
Vielleicht nicht die Antwort, die du gesucht hast aber:
![]() die Jungs dort haben einen richtig guten Job bezüglich LDAP/LDAPS gemacht. Eventuell durchforstest du den Source dort um ein paar Anleihen zu machen. |
AW: Umstellung LDAP auf SSL/TLS
Die Abfrage von LDAP_OPT_SSL liefert LDAP_LOCAL_ERROR.
Ob die Variable als NativeUInt, CARDINAL oder Pointer deklariert ist, spielt keine Rolle, die sind bei mir alle 32Bit. Ich vermute, TLS is bereits aktiviert und deshalb steht die Option SSL nicht zur Verfügung. Das bedeutet für mich, die Anleitung von MS ist nicht mehr aktuell oder unvollständig. Im Quelltext "LDAPAdmin" wird die Option LDAP_OPT_SSL nicht benutzt und LDAP_LOCAL_ERROR an einer Stelle ignoriert:
Delphi-Quellcode:
Ich versuch diese Variante...
if ldapSSL then
ldappld := ldap_sslinit(PChar(ldapServer), ldapPort,1) else ldappld := ldap_init(PChar(ldapServer), ldapPort); if Assigned(pld) then try LdapCheck(ldap_set_option(pld,LDAP_OPT_PROTOCOL_VERSION,@ldapVersion)); if ldapSSL or ldapTLS then begin res := ldap_set_option(pld, LDAP_OPT_SERVER_CERTIFICATE, @VerifyCert); if (res <> LDAP_SUCCESS) and (res <> LDAP_LOCAL_ERROR) then LdapCheck(res); CertServerName := PChar(ldapServer); end; CertUserAbort := false; if ldapTLS then begin res := ldap_start_tls_s(ldappld, nil, nil, nil, nil); if CertUserAbort then Abort; LdapCheck(res); end; case ldapAuthMethod of |
AW: Umstellung LDAP auf SSL/TLS
Liste der Anhänge anzeigen (Anzahl: 2)
Hi again,
with this code which is the same as mine above with one addition the connect
Code:
Also i installed Active Directory LightWeight Directory Service from Windows Features
procedure TForm10.LDAPConnect;
var pConn: PLDAP; Version: NativeUInt; CurrVer: NativeUInt; TimeOut: TLDAPTimeVal; begin pConn := ldap_sslinit('127.0.0.1', LDAP_SSL_PORT, 1); // pConn := ldap_init('localhost', LDAP_PORT); if not Assigned(pConn) then Exit; try Version := LDAP_VERSION3; if ldap_set_option(pConn, LDAP_OPT_PROTOCOL_VERSION, @Version) <> LDAP_SUCCESS then Exit; if ldap_get_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; Memo1.Lines.Add('Current SSL status : ' + BoolToStr(CurrVer <> 0, true)); if CurrVer = NativeUInt(LDAP_OPT_OFF) then begin CurrVer := NativeUInt(LDAP_OPT_ON); if ldap_set_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; end; // check again if ldap_get_option(pConn, LDAP_OPT_SSL, @CurrVer) <> LDAP_SUCCESS then Exit; Memo1.Lines.Add('Current SSL status : ' + BoolToStr(CurrVer <> 0, true)); TimeOut.tv_sec := 5; TimeOut.tv_usec := 0; if ldap_connect(pConn, @TimeOut) <> LDAP_SUCCESS then begin Memo1.Lines.Add('ldap_connect failed'); Exit; end; Memo1.Lines.Add('Connected'); Memo1.Lines.Add('Success'); finally ldap_unbind_s(pConn); end; end; Anhang 56845 Now the result also failed to connect still, because i didn't configure any certificate and not sure about what account i allowed as i clicked next ,next .... But from Wireshark the connection is established with TLS v1.2 and a Client Hello is sent from the app to ADS server but the server abruptly closed the connection, this is a symptom when the server doesn't have a valid certificate, i don't want to go through issuing a certificate for many reasons but the biggest one is i don't have a valid domain or a have access to real AD server on Windows OS server to issue trusted one. Wireshark : Anhang 56846 So i suggest to use wireshark to check if SSL/TLS is enabled instead of depending on LDAP_OPT_SSL, i doubt it might refer to client side certificate verification instead of what you think of the connection is TLS. See, using ldap_sslinit is already indicating the secure connection, so LDAP_OPT_SSL might not be the indicator, but again i might be wrong here, or may be it is reserved when using ldap_init instead of ldap_sslinit, i don't know. |
AW: Umstellung LDAP auf SSL/TLS
Zitat:
Der Handler SetTLS der LDAPAdmin TLDAPSession Klasse setzt den Wert:
Code:
So.. bevor das Werkl startet wird die TLS session gestartet. Dann wird natürlich kein ssl init aufgerufen...
procedure TLDAPSession.SetTLS(Value: Boolean);
begin if Connected and (Value <> ldapTLS) then begin if Value then LdapCheck(ldap_start_tls_s(ldappld, nil, nil, nil, nil)) else if not ldap_stop_tls_s(ldappld) then begin //MessageDlg(stStopTLSError, mtError, [mbOk], 0); Disconnect; end; end; ldapTLS := Value; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz