@@ -185,7 +185,10 @@ func (req *ModifyRequest) Replace(attrType string, attrVals []string) {
185185// - attrVals: A slice of strings representing the new values for the attribute.
186186func (ldapSession * Session ) OverwriteAttributeValues (distinguishedName string , attrName string , attrVals []string ) error {
187187 if len (attrVals ) == 0 {
188- ldapSession .FlushAttribute (distinguishedName , attrName )
188+ err := ldapSession .FlushAttributeValues (distinguishedName , attrName )
189+ if err != nil {
190+ return fmt .Errorf ("error flushing attribute %s of %s: %s" , attrName , distinguishedName , err )
191+ }
189192 } else {
190193 controls := NewControlsWithOIDs ([]string {LDAP_SERVER_PERMISSIVE_MODIFY_OID }, false )
191194
@@ -196,7 +199,7 @@ func (ldapSession *Session) OverwriteAttributeValues(distinguishedName string, a
196199 // Execute the modify request
197200 err := ldapSession .connection .Modify (m )
198201 if err != nil {
199- return fmt .Errorf ("error overwriting attribute %s of %s: %s " , attrName , distinguishedName , err )
202+ return fmt .Errorf ("error flushing attribute %s of %s: %w " , attrName , distinguishedName , err )
200203 }
201204 }
202205 return nil
@@ -325,15 +328,15 @@ func (ldapSession *Session) AddStringToAttributeList(distinguishedName string, a
325328 return nil
326329}
327330
328- // FlushAttribute flushes the attribute by deleting it
331+ // FlushAttributeValues flushes the attribute by deleting it
329332//
330333// Parameters:
331334// - dn: A string representing the distinguished name (DN) of the LDAP entry to be modified.
332335// - attributeName: A string representing the name of the attribute to be flushed.
333336//
334337// Returns:
335338// - An error object if the flush operation fails, otherwise nil.
336- func (ldapSession * Session ) FlushAttribute (distinguishedName string , attributeName string ) error {
339+ func (ldapSession * Session ) FlushAttributeValues (distinguishedName string , attributeName string ) error {
337340 // Create a modify request
338341 m := goldapv3 .NewModifyRequest (distinguishedName , nil )
339342 m .Replace (attributeName , []string {})
0 commit comments