Class: Puppet::Util::Windows::ADSI::UserProfile Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/windows.rb,
lib/puppet/util/windows/adsi.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.delete(sid) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/puppet/util/windows/adsi.rb', line 570

def self.delete(sid)
  begin
    Puppet::Util::Windows::ADSI.wmi_connection.Delete("Win32_UserProfile.SID='#{sid}'")
  rescue WIN32OLERuntimeError => e
    # https://social.technet.microsoft.com/Forums/en/ITCG/thread/0f190051-ac96-4bf1-a47f-6b864bfacee5
    # Prior to Vista SP1, there's no built-in way to programmatically
    # delete user profiles (except for delprof.exe). So try to delete
    # but warn if we fail
    raise e unless e.message.include?('80041010')

    Puppet.warning _("Cannot delete user profile for '%{sid}' prior to Vista SP1") % { sid: sid }
  end
end