Einzelnen Beitrag anzeigen

Benutzerbild von Phoenix
Phoenix
(Moderator)

Registriert seit: 25. Jun 2002
Ort: Hausach
7.610 Beiträge
 
#2

Re: System.DirectoryServices.Protocols: Attributwert löschen

  Alt 30. Sep 2008, 12:31
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.
Sebastian Gingter
Phoenix - 不死鳥, Microsoft MVP, Rettungshundeführer
Über mich: Sebastian Gingter @ Thinktecture Mein Blog: https://gingter.org
  Mit Zitat antworten Zitat