Startseite ¦  was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews ¦  sonstiges
kylix ¦  tutorials ¦  online shop ¦  fotos ¦  Add&Win Gewinnspiel


Willkommen Gast. Bitte einloggen oder registrieren.
21.05.2012, 10:41:19
Übersicht Hilfe Suche Einloggen Registrieren

+  SwissDelphiCenter Forum
|-+  German Forums
| |-+  WinAPI Forum
| | |-+  LDAP Abfrage. Kein Resultat wenn Bindestrich in Gruppenname!
« vorheriges nächstes »
Seiten: [1] Drucken
Autor Thema: LDAP Abfrage. Kein Resultat wenn Bindestrich in Gruppenname!  (Gelesen 3932 mal)
enemyleft
Newbie
*
Offline Offline

Beiträge: 4


« am: 28.08.2009, 07:34:31 »

Hallo

Ich lese mit folgender Funktion die Mitglieder einer Gruppe auf. Dies funktioniert auch wunderbar, bis ich für "MyObjName" einen Gruppenname angebe, der einen Bindestrich "-" enthält. Dann ist das Ergebnis leer... An was kann das liegen?

Code:
{*------------------------------------------------------------------------------
  this function lists the members of a group

  @param  ADsPath       ldap path to active directory
  @param  MyObjClass    specifies the object class in which you perform
                        the search
  @param  MyObjName     the name of the object you search after
  @param  list          this list is containing the search result
  @return               returns wether the search was a success or not
-------------------------------------------------------------------------------}
function ListMemberOf(ADsPath, MyObjClass, MyObjName: String; list: TStringList): Boolean;
var rs, conn, com : Variant;
    strFilter, strAttributes, strADS : string;
    arrVar: Array of variant;
    SearchObj: String;
    i:Integer;
    strTxt,strValue:String;
begin
  conn := CreateOleObject('ADODB.Connection');
  com := CreateOleObject('ADODB.Command');
  Result := True;
  try
    conn.Provider := 'ADsDSOObject';
    conn.open;
    com.ActiveConnection := conn;
    if MyObjClass = 'user' then
      SearchObj := 'sAMAccountName'
    else
      SearchObj := 'CN';
    strFilter := '(&(objectClass='+MyObjClass+')('+SearchObj+'='+MyObjName+'))';
    strAttributes := 'memberOf';
    strADS := '<'+ADsPath+'>;' + strFilter + ';' + strAttributes + ';subtree';
    Com.CommandText := strADS;
    Com.Properties['Page Size'] := 100000;
    Com.Properties['Searchscope'] := 2;
    Com.Properties['Cache Results'] := False;
    rs := Com.Execute;
    if Not rs.EOF then
    begin
      try
        arrVar := rs.Fields['memberOf'].Value;
      except
        SetLength(arrVar,1);
        arrVar[0] := 'is not member of a group ...';
      end;
    end
    else
      Result := False;
    Rs := NULL;
  finally
    com := NULL;
    conn.Close;
    conn := NULL;
  end;
  for i := 0 to Length(arrVar) - 1 do
  begin
    strTxt := arrVar[i];
    strValue := MidStr(strTxt,Pos('=',strTxt)+1,Pos(',',strTxt)-Pos('=',strTxt)-1);
    list.Add(strValue);
  end;
end;

Danke schonmal.

Gespeichert
Loïs Bégué
Global Moderator
Hero Member
*****
Offline Offline

Beiträge: 1718



WWW
« Antworten #1 am: 18.09.2009, 09:50:34 »

((** CROSS-POSTING ist wirklich UNSCHÖN **))
wir helfen gern... aber dein Umgang mit der Helper-Community solltest Du überdenken


Habe den Code zwar nicht getestet... aber mein erster Gedanke:

Manche Chars sollen (afaik) "escaped" werden d.h. mit einem vorangestellten "\" umgesetzt werden.

& => \&
! => \!
| => ... usw ...
=
<
>
,
+
-
"
'
;

Gespeichert

Prof.Y
Arpoon
Seiten: [1] Drucken 
« vorheriges nächstes »
Gehe zu:  


Einloggen mit Benutzername, Passwort und Sitzungslänge

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006, Simple Machines LLC Prüfe XHTML 1.0 Prüfe CSS