Class: Jamf::DirectoryBinding

Inherits:
APIObject show all
Includes:
Creatable, DirectoryBindingType, Updatable
Defined in:
lib/jamf/api/classic/api_objects/directory_binding.rb

Overview

Note:

“Jamf::DirectoryBinding.fetch name: ‘BindingName’” seems to be returning a 500 error in my test evironment. Use “Jamf::DirectoryBinding.fetch ‘BindingName’ instead.”

A Directory Binding object in the JSS These are rather complex objects, and contain settings specific to the directory object’s type.

Constant Summary collapse

DIRECTORY_BINDING_TYPE =

! You CAN update this

{
    open_directory: "Open Directory",
    active_directory: "Active Directory",
    powerbroker_identity_services: "PowerBroker Identity Services",
    admitmac: "ADmitMac",
    centrify: "Centrify"
}.freeze
DIRECTORY_BINDING_TYPE_CLASSES =
{
    "Open Directory" => Jamf::DirectoryBindingType::OpenDirectory,
    "Active Directory" => Jamf::DirectoryBindingType::ActiveDirectory,
    "PowerBroker Identity Services" => Jamf::DirectoryBindingType::PowerBroker,
    "ADmitMac" => Jamf::DirectoryBindingType::ADmitMac,
    "Centrify" => Jamf::DirectoryBindingType::Centrify
}
RSRC_BASE =

The base for REST resources of this class

'directorybindings'.freeze
RSRC_LIST_KEY =

the hash key used for the JSON list output of all objects in the JSS

:directory_bindings
RSRC_OBJECT_KEY =

The hash key used for the JSON object output. It’s also used in various error messages

:directory_binding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ DirectoryBinding

Note:

When creating an object with specific properties use the

Constructor objects name and then the settings. Ex: Creating an Active Directory object: Jamf::DirectoryBinding.make name: “Example Binding”, username: “BindingUser”, password: “SuperMonkey123”, computer_ou: “computers”, active_directory: { multiple_domains: false }, domain: your.domain.server

See Also:

  • APIObject.initialize


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 110

def initialize(**args)
    super

    if self.in_jss?
        @priority = @init_data[:priority]
        @domain = @init_data[:domain]
        @username = @init_data[:username]
        @password_sha256 = @init_data[:password_sha256]
        @computer_ou = @init_data[:computer_ou]
        @type = @init_data[:type]

        class_key = DIRECTORY_BINDING_TYPE.select { |k,v| v == @type }.map { |k,v| k }.first
        self.set_type_settings (DIRECTORY_BINDING_TYPE_CLASSES[@type.to_s].new @init_data[class_key])
    else
        # Build
        raise Jamf::MissingDataError, "domain must be provided." if @init_data[:domain].nil?
        raise Jamf::MissingDataError, "username must be provided." if @init_data[:username].nil?
        raise Jamf::MissingDataError, "computer_ou must be provided." if @init_data[:computer_ou].nil?
        raise Jamf::MissingDataError, "password must be provided when creating a DirectoryBinding object." if @init_data[:password].nil?
        raise Jamf::MissingDataError, "Type must be provided, one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." if @init_data[:type].nil?
        raise Jamf::InvalidDataError, "Type must be one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." unless DIRECTORY_BINDING_TYPE.keys.include? @init_data[:type]
        raise Jamf::InvalidDataError, "Priority must be between 1 and 10" if !@init_data[:priority].nil? && (@init_data[:priority] <= 1 || @init_data[:priority] >= 10)

        @domain = @init_data[:domain]
        @username = @init_data[:username]
        @computer_ou = @init_data[:computer_ou]
        @type = DIRECTORY_BINDING_TYPE[@init_data[:type]]
        @password = @init_data[:password]
        @priority = @init_data[:priority]

        @priority = 1 if @priority.nil?


        class_key = DIRECTORY_BINDING_TYPE.select { |k,v| v == @type }.map { |k,v| k }.first
        self.set_type_settings (DIRECTORY_BINDING_TYPE_CLASSES[@type.to_s].new @init_data[class_key])

    end

end

Instance Attribute Details

#computer_ouObject

Returns the value of attribute computer_ou.



98
99
100
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 98

def computer_ou
  @computer_ou
end

#domainObject

Returns the value of attribute domain.



95
96
97
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 95

def domain
  @domain
end

#idObject (readonly)

Attributes



92
93
94
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 92

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



93
94
95
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 93

def name
  @name
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#passwordObject

Returns the value of attribute password.



101
102
103
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 101

def password
  @password
end

#password_sha256Object (readonly)

Returns the value of attribute password_sha256.



97
98
99
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 97

def password_sha256
  @password_sha256
end

#priorityObject

Returns the value of attribute priority.



94
95
96
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 94

def priority
  @priority
end

#typeObject (readonly)

Returns the value of attribute type.



99
100
101
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 99

def type
  @type
end

#type_settingsObject (readonly)

Returns the value of attribute type_settings.



100
101
102
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 100

def type_settings
  @type_settings
end

#usernameObject

Returns the value of attribute username.



96
97
98
# File 'lib/jamf/api/classic/api_objects/directory_binding.rb', line 96

def username
  @username
end

Instance Method Details

#clone(new_name, api: nil, cnx: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • cnx (Jamf::Connection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An unsaved clone of this APIObject with the given name

Raises:

#name=(newname) ⇒ void Originally defined in module Updatable

This method returns an undefined value.

Change the name of this item Remember to #update to push changes to the server.

Parameters:

  • newname (String)

    the new name

Raises:

#set_type_settings(settings) ⇒ Object Originally defined in module DirectoryBindingType

#should_updateObject Originally defined in module DirectoryBindingType

Module Methods