The structure that is returned should be freed by calling ldap_control_free(3LDAP) , an LDAP API function.