![]() |
Active Directory und Trusted Domain
Ich könnte Hilfe gebrauchen. Danke!
Ich habe zwei Domänen DOM-A und DOM-B, die via Trusted Donain verbunden sind. Ich kann aus der Domäne DOM-A für den User X aus dem AD die Gruppen auslesen: select memberof from 'LDAP://DOM-A' where objectClass='person' and sAMAccountName='X' Damit ich aus der DOM-B die gruppen des Users auslesen kann, muss ich aus DOM-A den SID ermitteln und damit in DOM-B suchen: select objectSID from 'LDAP://DOM-A' where objectClass='person' and sAMAccountName='X' Liefert siwas: S-1-5-21-144191708-1486429690-1194094237-999999 Mit dem SID suche ich nun in DOM-B: select memberof from 'LDAP://DOM-B' where objectClass='foreignSecurityPrincipal' and Name='S-1-5-21-144191708-1486429690-1194094237-999999' Das Problem ist nun, dass das zwar eine Zeile zurückliefert, aber ich auf die Felder der Query nicht zugreifen kann. Etwas, das im Schritt ganz oben ohne Probleme funktioniert. Siehe Code unten.
Code:
Ich vermute, dass der Variant v da einen anderen Datentyp hat, aber welchen? Oder übersehe ich da was ganz anderes?
if (sSID <> '') then begin
sSQL := 'select memberof from ''LDAP://' + sDomain + ''' where objectClass=''foreignSecurityPrincipal'' and Name=' + QuotedStr(sSID); end else begin sSql := 'select memberof from ''LDAP://' + sDomain + ''' where objectClass=''person'' and sAMAccountName=' + QuotedStr(sUSername); end; qQuery.SQL.Text := sSql; qQuery.Open; s := ''; while not qQuery.EOF do begin i := qQuery.FieldCount; <---- es gibt 1 Feld for i := 0 to qQuery.FieldCount - 1 do begin try v := qQuery.Fields[i].Value; < --- v ist Variant nDim := VarArrayDimCount(v); <-- das hat Wert 0 bei Abfrage über SID nUpper := VarArrayHighBound(v, 1); < --- hier gibt es einen fehler, weil das Dimension 0 hat + wohl ein anderer Datentyp? nLower := VarArrayLowBound(v, 1); for n := nLower to nUpper do begin try s := s + ', ' + v[n]; except on e: Exception do begin o_Log.Log(e.message, llDebug); end; end; end; except on e: Exception do begin o_Log.Log(e.message, llDebug); end; end; end; |
AW: Active Directory und Trusted Domain
I am sorry for being understanding the question if full.
But i don't think LDAP and SQL works like that, please refer and research this filtering mechanism ![]() Might be better to use something like the following for specific SID
Code:
As for the empty but not so empty result, it might be the Null SID
1.2.840.113556.1.4.1941:=(
![]() I might be wrong though, and sorry for that. |
AW: Active Directory und Trusted Domain
Mit VarIsType müsste sich ermitteln lassen, von welchem Typ v ist.
Mit VarIsArray ließe sich prüfen, ob v überhaupt ein Array ist. VarIsEmpty prüft, ob überhaupt was in v drinne ist. Vermutlich wirst Du Dich da durch die Routinen aus der Doku ![]() LDAP ist bei mir lange her, aber es war nie wirklich witzig, sich damit zu befassen :-( Eventuell kannst Du mit sowas in der Art weiterkommen:
Delphi-Quellcode:
ShowMessage(VarTypeAsText(VarType(v)));
Statt ShowMessage ggfls. einfach im Debugger "nachfragen" ;-) |
AW: Active Directory und Trusted Domain
Zitat:
|
AW: Active Directory und Trusted Domain
Zitat:
Ich hab hier zum Testen natürlich nicht so eine AD-Struktur. Das ist beim Kunden. Natürlich. :- / |
AW: Active Directory und Trusted Domain
Beim Kunden ist immer alles anders, egal welche Fehler, Besonderheiten, ... Du "abklapperst". Es gibt (leider) immer einen Kunden, bei dem es dann doch noch 'ne weitere Alternative gibt :-(
![]() Ergänze doch Deine Fehlerbehandlung jeweils um
Delphi-Quellcode:
Dann bekommst Du bei den Sonderlocken der Kundensysteme direkt etwas weitergehende Infos.
o_Log.Log(e.message, llDebug);
o_Log.Log(VarTypeAsText(VarType(v)), llDebug); Könnte eventuell ![]() |
AW: Active Directory und Trusted Domain
Zitat:
Jetzt muss ich nur mehr die Gruppen in der Trusted Domain finden. |
AW: Active Directory und Trusted Domain
Zitat:
I think you need to refine the query and go after "Ldap-Display-Name" from ![]() I am sorry if i still missing something, though i don't want to waste your time, but it doesn't make sense to me to make the SQL query answer and parse the security objects, it logical to parse the SQL outside the AD controller, and make it use the standard query with filters to talk with the controller, also the controller should NOT be parsing any SQL, while the LDAP SQL parser should NOT be able to parse the details of the Objects, thus minimizing the attack surface, here why the filters should work and in my opinion it is the only way, again this is my take in designing such critical system, in other words the SQL here is merely an interpreter for AD query. |
AW: Active Directory und Trusted Domain
MemberOf as well as Member is an enumeration and contains a list of all Users rsp Groups. SQL works quite ok, so this is not the problem. In contrary to the docs, LIKE is not suported, but " = '*vvv'" instead of "LIKE '%vvv'". Additionally wrong spelled or non exiting attributes do not generate an error, but return Null. So you my receive one row, but with no data.
Finally I came up with a solution, that - searches for the groups for a user - identifies the SID of the user - creates a list of the groups of the trusted domain - checks if the SID is in the list of members of the group If anybody is interested in the SQL statements or the code, that makes the SID readable and comparable, I´d be happy to post this here. |
AW: Active Directory und Trusted Domain
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:01 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