public static void doCleanup(LdapConnection conn, System.String userdn, System.String groupdn)
{
// since we have modified the user's attributes and failed to
// modify the group's attribute, we need to delete the modified
// user's attribute values.
// modifications for user
LdapModification[] modUser = new LdapModification[2];
// Delete the groupdn from the user's attributes
LdapAttribute membership = new LdapAttribute("groupMembership", groupdn);
modUser[0] = new LdapModification(LdapModification.DELETE, membership);
LdapAttribute security = new LdapAttribute("securityEquals", groupdn);
modUser[1] = new LdapModification(LdapModification.DELETE, security);
try
{
// Modify the user's attributes
conn.Modify(userdn, modUser);
System.Console.Out.WriteLine("Deleted the modified user's attribute values.");
}
catch (LdapException e)
{
System.Console.Out.WriteLine("Could not delete modified user's attributes: " + e.LdapErrorMessage);
}
catch(Exception e)
{
Console.WriteLine("Error:" + e.Message);
return;
}
return ;
}