Autor Beitrag
cherry
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

WinXP - Professional
RAD Studio 2009
BeitragVerfasst: Mo 24.08.09 13:58 
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?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
{*------------------------------------------------------------------------------ 
  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

_________________
AM I TOO SEXY?
Ist das nur mein Gefühl, oder ist die ganze Welt verrückt geworden!?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 24.08.09 14:38 
Moin!

Schonmal mit Quoting versucht? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
cherry Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

WinXP - Professional
RAD Studio 2009
BeitragVerfasst: Mo 24.08.09 14:40 
user profile iconNarses hat folgendes geschrieben Zum zitierten Posting springen:
Moin!

Schonmal mit Quoting versucht? :nixweiss:

cu
Narses


Hmm was ist das und wie mach ich das? :lol:
Meinst du mit Anführungszeichen??? Ja, habs mit ' und " versucht, geht auch net!

_________________
AM I TOO SEXY?
Ist das nur mein Gefühl, oder ist die ganze Welt verrückt geworden!?
cherry Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

WinXP - Professional
RAD Studio 2009
BeitragVerfasst: Fr 28.08.09 07:29 
*push*

_________________
AM I TOO SEXY?
Ist das nur mein Gefühl, oder ist die ganze Welt verrückt geworden!?
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 29.08.09 23:22 
Das - muss eigentlich nicht escaped werden, aber versuch es mal mit einem \ davor.