Class: JSS::DirectoryBinding

Inherits:
APIObject show all
Includes:
Creatable, DirectoryBindingType, Updatable
Defined in:
lib/jss/api_object/directory_binding.rb,
lib/jss.rb

Overview

Note:

“JSS::DirectoryBinding.fetch name: 'BindingName'” seems to be returning a 500 error in my test evironment. Use “JSS::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" => JSS::DirectoryBindingType::OpenDirectory,
    "Active Directory" => JSS::DirectoryBindingType::ActiveDirectory,
    "PowerBroker Identity Services" => JSS::DirectoryBindingType::PowerBroker,
    "ADmitMac" => JSS::DirectoryBindingType::ADmitMac,
    "Centrify" => JSS::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: JSS::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/jss/api_object/directory_binding.rb', line 110

def initialize(args = {})
    super args

    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 JSS::MissingDataError, "domain must be provided." if @init_data[:domain].nil?
        raise JSS::MissingDataError, "username must be provided." if @init_data[:username].nil?
        raise JSS::MissingDataError, "computer_ou must be provided." if @init_data[:computer_ou].nil?
        raise JSS::MissingDataError, "password must be provided when creating a DirectoryBinding object." if @init_data[:password].nil?
        raise JSS::MissingDataError, "Type must be provided, one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." if @init_data[:type].nil?
        raise JSS::InvalidDataError, "Type must be one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." unless DIRECTORY_BINDING_TYPE.keys.include? @init_data[:type]
        raise JSS::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/jss/api_object/directory_binding.rb', line 98

def computer_ou
  @computer_ou
end

#domainObject

Returns the value of attribute domain.



95
96
97
# File 'lib/jss/api_object/directory_binding.rb', line 95

def domain
  @domain
end

#idObject (readonly)

Attributes



92
93
94
# File 'lib/jss/api_object/directory_binding.rb', line 92

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



93
94
95
# File 'lib/jss/api_object/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/jss/api_object/directory_binding.rb', line 101

def password
  @password
end

#password_sha256Object (readonly)

Returns the value of attribute password_sha256.



97
98
99
# File 'lib/jss/api_object/directory_binding.rb', line 97

def password_sha256
  @password_sha256
end

#priorityObject

Returns the value of attribute priority.



94
95
96
# File 'lib/jss/api_object/directory_binding.rb', line 94

def priority
  @priority
end

#typeObject (readonly)

Returns the value of attribute type.



99
100
101
# File 'lib/jss/api_object/directory_binding.rb', line 99

def type
  @type
end

#type_settingsObject (readonly)

Returns the value of attribute type_settings.



100
101
102
# File 'lib/jss/api_object/directory_binding.rb', line 100

def type_settings
  @type_settings
end

#usernameObject

Returns the value of attribute username.



96
97
98
# File 'lib/jss/api_object/directory_binding.rb', line 96

def username
  @username
end

Instance Method Details

#clone(new_name, api: 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

  • api (JSS::APIConnection) (defaults to: nil)

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

Returns:

  • (APIObject)

    An uncreated clone of this APIObject with the given name

Raises:

#createInteger Originally defined in module Creatable

Create a new object in the JSS.

Parameters:

  • api (JSS::APIConnection)

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

Returns:

  • (Integer)

    the jss ID of the newly created object

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

#updateBoolean Originally defined in module Updatable

Save changes to the JSS

Returns:

  • (Boolean)

    success

Raises: