Module: Puppet::Util::Windows::ADSI::Shared
Instance Method Summary collapse
- #get_sids(adsi_child_collection) ⇒ Object
- #name_sid_hash(names) ⇒ Object
- #parse_name(name) ⇒ Object
- #uri(name, host = '.') ⇒ Object
Instance Method Details
#get_sids(adsi_child_collection) ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/puppet/util/windows/adsi.rb', line 124 def get_sids(adsi_child_collection) sids = [] adsi_child_collection.each do |m| sids << Puppet::Util::Windows::SID.octet_string_to_sid_object(m.objectSID) end sids end |
#name_sid_hash(names) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/puppet/util/windows/adsi.rb', line 133 def name_sid_hash(names) return {} if names.nil? || names.empty? sids = names.map do |name| sid = Puppet::Util::Windows::SID.name_to_sid_object(name) raise Puppet::Error.new( "Could not resolve name: #{name}" ) if !sid [sid.to_s, sid] end Hash[ sids ] end |
#parse_name(name) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/puppet/util/windows/adsi.rb', line 112 def parse_name(name) if name =~ /\// raise Puppet::Error.new( "Value must be in DOMAIN\\user style syntax" ) end matches = name.scan(/((.*)\\)?(.*)/) domain = matches[0][1] || '.' account = matches[0][2] return account, domain end |
#uri(name, host = '.') ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/puppet/util/windows/adsi.rb', line 101 def uri(name, host = '.') if sid_uri = Puppet::Util::Windows::ADSI.sid_uri_safe(name) then return sid_uri end host = '.' if ['NT AUTHORITY', 'BUILTIN', Socket.gethostname].include?(host) # group or user account_type = self.name.split('::').last.downcase Puppet::Util::Windows::ADSI.uri(name, account_type, host) end |