computer_name()
click to toggle source
def computer_name
unless @computer_name
buf = " " * 128
Win32API.new('kernel32', 'GetComputerName', ['P','P'], 'I').call(buf, buf.length.to_s)
@computer_name = buf.unpack("A*")
end
@computer_name
end
computer_uri()
click to toggle source
def computer_uri
"WinNT://#{computer_name}"
end
connect(uri)
click to toggle source
def connect(uri)
begin
WIN32OLE.connect(uri)
rescue Exception => e
raise Puppet::Error.new( "ADSI connection error: #{e}" )
end
end
connectable?(uri)
click to toggle source
def connectable?(uri)
begin
!! connect(uri)
rescue
false
end
end
create(name, resource_type)
click to toggle source
def create(name, resource_type)
Puppet::Util::ADSI.connect(computer_uri).Create(resource_type, name)
end
delete(name, resource_type)
click to toggle source
def delete(name, resource_type)
Puppet::Util::ADSI.connect(computer_uri).Delete(resource_type, name)
end
execquery(query)
click to toggle source
def execquery(query)
wmi_connection.execquery(query)
end
sid_for_account(name)
click to toggle source
def sid_for_account(name)
Puppet.deprecation_warning "Puppet::Util::ADSI.sid_for_account is deprecated and will be removed in 3.0, use Puppet::Util::Windows::SID.name_to_account instead."
Puppet::Util::Windows::Security.name_to_sid(name)
end
uri(resource_name, resource_type)
click to toggle source
def uri(resource_name, resource_type)
"#{computer_uri}/#{resource_name},#{resource_type}"
end
wmi_connection()
click to toggle source
def wmi_connection
connect(wmi_resource_uri)
end
wmi_resource_uri( host = '.' )
click to toggle source
def wmi_resource_uri( host = '.' )
"winmgmts:{impersonationLevel=impersonate}!//#{host}/root/cimv2"
end