Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#8

Re: Neue Attribute mit LDAP hinzufügen

  Alt 19. Aug 2007, 18:22
Hallo Rolf,

ich habe mir deinen Code mal angesehen, ein wenig umgeformt und kommentiert.

Delphi-Quellcode:
procedure TDemoForm.ButtonClick(Sender: TObject);
var
  conn: LdapConnection;
  entries: LdapEntryList;
  entry: LdapEntry;
  newEntry: LdapEntry;
begin
  conn := LdapConnection.Create;

  // quick hack to get read access in spite of protocol error
  // actually we need strong authorization to apply changes
  try conn.Open('www.openldap.com') except end;

  // create container for search results
  entries := LdapEntryList.Create;

  // execute subtree search
  conn.Search(entries, 'dc=OpenLDAP,dc=org', '(objectClass=openLDAPperson)');

  // single out second entry
  entry := entries.GetEntry(1);

  // clone entry
  newEntry := LdapEntry.Create(entry);

  // change location
  newEntry.Modify('l', 'Stuttgart');

  // issue mod request
  conn.Modify(entry, newEntry);

  // house keeping
  entry.Free;
  newEntry.Free;
  entries.Free;
  conn.Close;
  conn.Free;
end;
Grüße vom marabu
  Mit Zitat antworten Zitat