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

Public Class Methods

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

Public Instance Methods

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