Class: Puppet::Util::Windows::ADSI::Group Private
- Inherits:
-
ADSIObject
- Object
- ADSIObject
- Puppet::Util::Windows::ADSI::Group
- 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.
Instance Attribute Summary
Attributes inherited from ADSIObject
Class Method Summary collapse
- .create(name) ⇒ Object private
- .list_all ⇒ Object private
Instance Method Summary collapse
- #add_member_sids(*sids) ⇒ Object private
-
#members ⇒ Object
(also: #member_sids)
private
returns Puppet::Util::Windows::SID::Principal[] may contain objects that represent unresolvable SIDs qualified account names are returned by calling #domain_account.
- #remove_member_sids(*sids) ⇒ Object private
- #set_members(desired_members, inclusive = true) ⇒ Object private
Methods inherited from ADSIObject
#[], #[]=, #commit, delete, each, exists?, get_sids, #initialize, localized_domains, name_sid_hash, #native_object, #object_class, parse_name, #sid, #uri, uri
Constructor Details
This class inherits a constructor from Puppet::Util::Windows::ADSI::ADSIObject
Class Method Details
.create(name) ⇒ 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.
604 605 606 607 608 |
# File 'lib/puppet/util/windows/adsi.rb', line 604 def create(name) # Windows error 2224: The account already exists. raise Puppet::Error.new( _("Cannot create group if user '%{name}' exists.") % { name: name } ) if Puppet::Util::Windows::ADSI::User.exists?(name) new(name, Puppet::Util::Windows::ADSI.create(name, @object_class)) end |
.list_all ⇒ 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.
600 601 602 |
# File 'lib/puppet/util/windows/adsi.rb', line 600 def list_all Puppet::Util::Windows::ADSI.execquery('select name from win32_group where localaccount = "TRUE"') end |
Instance Method Details
#add_member_sids(*sids) ⇒ 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.
611 612 613 614 615 |
# File 'lib/puppet/util/windows/adsi.rb', line 611 def add_member_sids(*sids) sids.each do |sid| native_object.Add(Puppet::Util::Windows::ADSI.sid_uri(sid)) end end |
#members ⇒ Object Also known as: member_sids
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.
returns Puppet::Util::Windows::SID::Principal[] may contain objects that represent unresolvable SIDs qualified account names are returned by calling #domain_account
626 627 628 |
# File 'lib/puppet/util/windows/adsi.rb', line 626 def members self.class.get_sids(native_object.Members) end |
#remove_member_sids(*sids) ⇒ 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.
617 618 619 620 621 |
# File 'lib/puppet/util/windows/adsi.rb', line 617 def remove_member_sids(*sids) sids.each do |sid| native_object.Remove(Puppet::Util::Windows::ADSI.sid_uri(sid)) end end |
#set_members(desired_members, inclusive = true) ⇒ 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.
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/puppet/util/windows/adsi.rb', line 631 def set_members(desired_members, inclusive = true) return if desired_members.nil? current_hash = Hash[ self.member_sids.map { |sid| [sid.sid, sid] } ] desired_hash = self.class.name_sid_hash(desired_members) # First we add all missing members if !desired_hash.empty? members_to_add = (desired_hash.keys - current_hash.keys).map { |sid| desired_hash[sid] } add_member_sids(*members_to_add) end # Then we remove all extra members if inclusive if inclusive if desired_hash.empty? members_to_remove = current_hash.values else members_to_remove = (current_hash.keys - desired_hash.keys).map { |sid| current_hash[sid] } end remove_member_sids(*members_to_remove) end end |