Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   System.DirectoryServices.Protocols: Attributwert löschen (https://www.delphipraxis.net/121557-system-directoryservices-protocols-attributwert-loeschen.html)

Phoenix 30. Sep 2008 09:55


System.DirectoryServices.Protocols: Attributwert löschen
 
Hi,

Ich steh grad wie der Ochs' vorm Berg: Ich habe ein Objekt in einem LDAP, mit einem Attribut das ca. ~1500 Werte hat.
Zugriff auf das LDAP habe ich via S.DS.P.

Von diesem einen Attribut muss ich nun je nachdem 0 bis n (n in der Regel deutlich kleiner 1500) Werte löschen, finde mit S.DS.P aber gerade keine Möglichkeit, nur einen einzelnen Wert gezielt zu löschen, - ich kann immer nur irgendwie das ganze Attribut anpacken. Müsste also eigentlich alle nicht zu löschenden Werte in ein neues Attribut stecken und das dann austauschen.

Das ist mir persönlich aber etwas arg viel Overhead. Geht da was einfacheres?

Phoenix 30. Sep 2008 12:31

Re: System.DirectoryServices.Protocols: Attributwert löschen
 
Ah.. habs selber:

Code:
var modification = new DirectoryAttributeModification();
modification.Name = "member"; // Attributname
modification.Operation = DirectoryAttributeOperation.Delete;

foreach (entry in list)
{
   if (NeedToDelete(entry)
      modification.Add(entry);
}

if (modification.Count > 0)
{
   try
   {
      var request = new ModifyRequest(LdapObject.DistinguishedName, modification);
      ModifyResponse response = (ModifyResponse)LDAPConnection.SendRequest(request);

      if (response.ResultCode != ResultCode.Success)
         throw new InvalidOperationException("Ldap Error: " + response.ErrorMessage);
   }
}
Damit werden nur die Werte aus dem Attribut gelöscht, die in der DirectoryAttributeModification angegeben wurden.


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz