# module Puppet::Util::ADSI

### Public Instance Methods

computer_name() click to toggle source

    # File lib/puppet/util/adsi.rb, line 27
    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

    # File lib/puppet/util/adsi.rb, line 36
    def computer_uri
      "WinNT://#{computer_name}"
    end

connect(uri) click to toggle source

    # File lib/puppet/util/adsi.rb, line 11
    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

    # File lib/puppet/util/adsi.rb, line 3
    def connectable?(uri)
      begin
        !! connect(uri)
      rescue
        false
      end
    end

create(name, resource_type) click to toggle source

    # File lib/puppet/util/adsi.rb, line 19
    def create(name, resource_type)
      Puppet::Util::ADSI.connect(computer_uri).Create(resource_type, name)
    end

delete(name, resource_type) click to toggle source

    # File lib/puppet/util/adsi.rb, line 23
    def delete(name, resource_type)
      Puppet::Util::ADSI.connect(computer_uri).Delete(resource_type, name)
    end

execquery(query) click to toggle source

    # File lib/puppet/util/adsi.rb, line 52
    def execquery(query)
      wmi_connection.execquery(query)
    end

sid_for_account(name) click to toggle source

    # File lib/puppet/util/adsi.rb, line 56
    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

    # File lib/puppet/util/adsi.rb, line 44
    def uri(resource_name, resource_type)
      "#{computer_uri}/#{resource_name},#{resource_type}"
    end

wmi_connection() click to toggle source

    # File lib/puppet/util/adsi.rb, line 48
    def wmi_connection
      connect(wmi_resource_uri)
    end

wmi_resource_uri( host = '.' ) click to toggle source

    # File lib/puppet/util/adsi.rb, line 40
    def wmi_resource_uri( host = '.' )
      "winmgmts:{impersonationLevel=impersonate}!//#{host}/root/cimv2"
    end