class Puppet::Util::Windows::ADSI::Group

Public Class Methods

create(name) click to toggle source
    # File lib/puppet/util/windows/adsi.rb
596 def create(name)
597   # Windows error 2224: The account already exists.
598   raise Puppet::Error.new( _("Cannot create group if user '%{name}' exists.") % { name: name } ) if Puppet::Util::Windows::ADSI::User.exists?(name)
599   new(name, Puppet::Util::Windows::ADSI.create(name, @object_class))
600 end
list_all() click to toggle source
    # File lib/puppet/util/windows/adsi.rb
592 def list_all
593   Puppet::Util::Windows::ADSI.execquery('select name from win32_group where localaccount = "TRUE"')
594 end

Public Instance Methods

add_member_sids(*sids) click to toggle source
    # File lib/puppet/util/windows/adsi.rb
603 def add_member_sids(*sids)
604   sids.each do |sid|
605     native_object.Add(Puppet::Util::Windows::ADSI.sid_uri(sid))
606   end
607 end
member_sids()
Alias for: members
members() click to toggle source

returns Puppet::Util::Windows::SID::Principal[] may contain objects that represent unresolvable SIDs qualified account names are returned by calling domain_account

    # File lib/puppet/util/windows/adsi.rb
618 def members
619   self.class.get_sids(native_object.Members)
620 end
Also aliased as: member_sids
remove_member_sids(*sids) click to toggle source
    # File lib/puppet/util/windows/adsi.rb
609 def remove_member_sids(*sids)
610   sids.each do |sid|
611     native_object.Remove(Puppet::Util::Windows::ADSI.sid_uri(sid))
612   end
613 end
set_members(desired_members, inclusive = true) click to toggle source
    # File lib/puppet/util/windows/adsi.rb
623 def set_members(desired_members, inclusive = true)
624   return if desired_members.nil?
625 
626   current_hash = Hash[ self.member_sids.map { |sid| [sid.sid, sid] } ]
627   desired_hash = self.class.name_sid_hash(desired_members)
628 
629   # First we add all missing members
630   if !desired_hash.empty?
631     members_to_add = (desired_hash.keys - current_hash.keys).map { |sid| desired_hash[sid] }
632     add_member_sids(*members_to_add)
633   end
634 
635   # Then we remove all extra members if inclusive
636   if inclusive
637     if desired_hash.empty?
638       members_to_remove = current_hash.values
639     else
640       members_to_remove = (current_hash.keys - desired_hash.keys).map { |sid| current_hash[sid] }
641     end
642 
643     remove_member_sids(*members_to_remove)
644   end
645 end