Announcement

Collapse
No announcement yet.

ADSI SQL-Problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ADSI SQL-Problem

    Hi,

    ich möchte das ADSI abfragen und benutzte dazu die folgende SQL-Anweisung:

    SELECT name FROM "ldap://cn=users,dc=gf" WHERE objectClass = "user"

    Dabei bekomme ich unte D7 immer die Meldung:

    Der Befehl enthält mindestens einen Fehler.

    Ich habe schon alles möglich probiert, finde aber keinen Fehler. Bin ich wirklich so blind? Der Verbindungstest unter Aufbau-Connectionstring funktioniert jedenfalls.

    Vielen Dank

    Detlef Fricke

  • #2
    Hi,
    schade, schade. Keiner einen Tip? War die Frage zu blöd?

    Vielleicht noch mal das Problem. Ich möchte mit einer ADOQuery das Active Direktory auf einem W2k Server abfragen. Dabei erhalte ich die oben geschilderte Fehlermeldung, wenn ich die Datenmenge im Objektinspektor auf aktiv setzen will. Zur Laufzeit erscheint dagegen eine Exeption EDatabaseError: Acces denied for user ... Wenn ich ein "ähnliches" VB-Script wie:

    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADSDSOOBJECT"
    adoConnection.Open "","cn=Administrator,cn=users,dc=gf", "password"

    set adoRecordset = adoConnection.Execute ("<LDAP://cn=users,dc=gf>;(objectClass=User);Name,ADsPath;Su btree")

    str = ""
    while Not AdoRecordset.EOF
    str = str & adoRecordset.Fields.Item("Name").Value & vbCrLF & adoRecordset.Fields.Item("ADsPath").Value
    adoRecordset.movenext
    wend
    wscript.Echo str

    ausführe, läuft alles einwandfrei, wobei Administratoranmeldename und Password identisch wie unter Delphi sind.

    Hilfe, ich komm nicht weiter.

    Gruß Detle

    Comment


    • #3
      Hallo,

      funktioniert auf diesem Rechner das folgende Beispiel?

      <pre>
      <b>unit</b> ADO_ADSI_SELECTFrmMain;

      <b>interface</b>

      <b>uses</b>
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, DB, Grids, DBGrids, ADODB;

      <b>type</b>
      TForm1 = <b>class</b>(TForm)
      ADODataSet1: TADODataSet;
      DBGrid1: TDBGrid;
      DataSource1: TDataSource;
      Button1: TButton;
      ADOConnection1: TADOConnection;
      <b>procedure</b> Button1Click(Sender: TObject);
      <b>private</b>
      <font color="#003399"><i>{ Private-Deklarationen }</i></font>
      <b>public</b>
      <font color="#003399"><i>{ Public-Deklarationen }</i></font>
      <b>end</b>;

      <b>var</b>
      Form1: TForm1;

      <b>implementation</b>

      <font color="#003399"><i>{$R *.dfm}</i></font>

      <b>uses</b> ComObj, ADOInt, ActiveDs_TLB;

      <b>procedure</b> TForm1.Button1Click(Sender: TObject);
      <b>var</b>
      aCon : _Connection;
      aCommand : _Command;
      aRS : _RecordSet;
      vRows : OleVariant;
      <b>begin</b>
      aCon := CoConnection.Create;
      aCon.Provider := <font color="#9933CC">'ADsDSOObject'</font>;
      OleVariant(aCon).Open;
      aCommand := CoCommand.Create;
      aCommand.Set_ActiveConnection(aCon);
      aCommand.CommandText :=<font color="#9933CC">'SELECT AdsPath,Name FROM '</font><font color="#9933CC">'LDAP://DC=OssiSoft,DC=local'</font><font color="#9933CC">''</font> ;
      <font color="#003399"><i>// Delphi-Bug korrigieren</i></font>
      OleVariant(aCommand).Properties[<font color="#9933CC">'searchscope'</font>] := ADS_SCOPE_ONELEVEL;
      aRS := aCommand.Execute(vRows, EmptyParam, 0);
      ADODataSet1.Recordset := aRS;
      DataSource1.DataSet := ADODataSet1;
      DBGrid1.DataSource := DataSource1;
      ShowMessage(<font color="#9933CC">'Fertig'</font>);
      <b>end</b>;

      <b>end</b>.
      </pre>

      DFM:

      <pre>
      <b>object</b> Form1: TForm1
      Left = 192
      Top = 114
      Width = 870
      Height = 640
      Caption = <font color="#9933CC">'Form1'</font>
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = <font color="#9933CC">'MS Sans Serif'</font>
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      <b>object</b> DBGrid1: TDBGrid
      Left = 24
      Top = 104
      Width = 665
      Height = 361
      DataSource = DataSource1
      TabOrder = 0
      TitleFont.Charset = DEFAULT_CHARSET
      TitleFont.Color = clWindowText
      TitleFont.Height = -11
      TitleFont.Name = <font color="#9933CC">'MS Sans Serif'</font>
      TitleFont.Style = []
      <b>end</b>
      <b>object</b> Button1: TButton
      Left = 24
      Top = 32
      Width = 75
      Height = 25
      Caption = <font color="#9933CC">'Button1'</font>
      TabOrder = 1
      OnClick = Button1Click
      <b>end</b>
      <b>object</b> ADODataSet1: TADODataSet
      Parameters = &lt;&gt;
      Left = 24
      Top = 64
      <b>end</b>
      <b>object</b> DataSource1: TDataSource
      DataSet = ADODataSet1
      Left = 56
      Top = 64
      <b>end</b>
      <b>object</b> ADOConnection1: TADOConnection
      ConnectionString = <font color="#9933CC">'Provider=ADsDSOObject;Encrypt Password=False'</font>
      LoginPrompt = False
      Mode = cmRead
      Provider = <font color="#9933CC">'ADsDSOObject'</font>
      Left = 120
      Top = 24
      <b>end</b>
      <b>end</b>
      </pre&gt

      Comment


      • #4
        Hallo Herr Kosch,

        tja, der Code läuft! Und mein Fehler ist auch klar. Ich habe den SQL-String so eingegeben wie oben, also mit Gänsehäkchen. Ich hatte natürlich auch die andere Variante versucht, aber zu dem Zeitpunkt muss wohl noch was anderes quer gelegen haben.

        Jedenfalls vielen Dank, dass Sie sich meiner erbarmt haben.

        Viele Grüße

        Detlef Frick

        Comment

        Working...
        X