AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Liste der Domain-User

Ein Thema von UweR · begonnen am 9. Aug 2005 · letzter Beitrag vom 24. Apr 2006
Antwort Antwort
Madlax

Registriert seit: 30. Aug 2004
Ort: Erkelenz
9 Beiträge
 
Delphi 7 Enterprise
 
#1

Re: Liste der Domain-User

  Alt 9. Aug 2005, 13:34
Hallo UweR,

ich habe eben mal meine Sources durchgeschaut und habe was gefunden, dass dir wahrscheinlich helfen wird. Dabei handelt es sich um eine Funktion die dir alle User in einer Domäne per ADOQuery zusammensammelt.

Delphi-Quellcode:
Uses ActiveDS_TLB;

//Binds to an ADSI object using the current credentials.
Function ADsGetObject( lpszPathName: WideString;
                       Const riid : TGUID;
                         Out ppObject ): HRESULT; Safecall;

Function ADsGetObject; External 'activeds.dll';

Function GetObject( Path: String ): IDispatch;
Begin
  ADsGetObject( Path, IDispatch, Result );
End; {Of GetObject}

Procedure TfrmADSIx.Users;
Var iAdRootDSE : IADs;
    Conn : TADOConnection;
    Data : TADODataSet;
    Cmd : TADOCommand;
    varDefaultNC: Variant;
    strQuery : String;
Begin
  //Find users by searching Active Directory.
  //This can be run from any DSClient-enabled computer.
  Conn := TADOConnection.Create( NIL );
  Data := TADODataSet.Create( NIL );
  Cmd := TADOCommand.Create( NIL );

  //Get the default naming context.
  iAdRootDSE := GetObject( 'LDAP://RootDSE' ) As IADs;
  varDefaultNC := iAdRootDSE.Get( 'defaultNamingContext' );

  //Open the connection.
  Conn.Provider := 'ADsDSOObject';
  Conn.LoginPrompt := False;
  Conn.Open;
    
  //Build the query to find all of the users.
  strQuery := '<LDAP://' + varDefaultNC + '>;(objectClass=user);name;subtree';

  Cmd.Connection := Conn;
  Cmd.ParamCheck := False;
  Cmd.CommandText := strQuery;
  Data.Recordset := Cmd.Execute;

  //Iterate through the results.
  While Not Data.Eof Do Begin
      ShowMessage( 'Name: ' + Data.FieldByName( 'name' ).AsString );
      Data.Next;
  End;

  //Clean up.
  Data.Free;
  Cmd.Free;
  Conn.Free;
  iAdRootDSE := NIL;
End; {Of Users}
In diesem Beispiel wurde activeds.dll als Typbibliothek nach Delphi importiert.
Die Funktion "ADsGetObject" befindet sich ebenfalls in dieser Dll, nähere Infos dazu findest du im MSDN.
Gruß,
Madlax
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:06 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