LDAP

For the LDAP collection resource, you can use an object value to return another value for the same object.

Getting an {ldapId}

IBM Spectrum Protect Plus assigns an ID, {ldapId}, to each LDAP server.

Method and URI: To convert the value of an object for an LDAP server, use a GET method with a URI:

GET     https://{hostname|IP}/api/ldap

Path: Response body (JSON) > ldapServers > hostAddress & id

Example: Assume that you added an LDAP server (IPv4 address 10.0.0.111) to IBM Spectrum Protect Plus. A Python snippet that is similar to the following example can be used to return its ID, 1012:

object_name = "10.0.0.111"

_response = requests.get('https://' + spp_ipv4 + '/api/ldap',
    headers=..., verify=...)

_response_json = json.loads(_response.text)    # Convert to JSON

object_json = _response_json['ldapServers']

for keys in object_json:
    if keys['hostAddress'] == object_name:
        object_id = keys['id']

print(object_id)
1012

Getting an {ldapHref}

IBM Spectrum Protect Plus assigns a URL {ldapHref} to the LDAP server that was registered with IBM Spectrum Protect Plus.

Method and URI: To convert the value of an object for an identity, use a GET method with a URI:

GET     https://{hostname|IP}/api/ldap

Path: Response body (JSON) > ldapServers > hostAddress & links > self > href

Example: Assume that you added an LDAP server (IPv4 address 10.0.0.111), to IBM Spectrum Protect Plus. A Python snippet that is similar to the following example can be used to return its {ldapHref} value, https://10.0.0.111/api/ldap/1012:

object_hostAddress = "10.0.0.111"

_response = requests.get('https://' + spp_ipv4 + '/api/ldap',
    headers={...}, verify=...)

_response_json = json.loads(_response.text)    # Convert to JSON

object_json = _response_json['ldapServers']

for keys in object_json:
    if keys['hostAddress'] == object_hostAddress:
        object_href = keys['links']['self']['href']

print(object_href)
https://10.0.0.111/api/ldap/1012/user/Sales-Americas

Getting an {ldapUserHref}

IBM Spectrum Protect Plus assigns a URL, {ldapUserHref}, to an LDAP server common name.

Method and URI: To convert the value of an object for an identity, use a GET method with a URI:

GET     https://{hostname|IP}/api/ldap/{ldapId}/user

Path: Response body (JSON) > users > cn & links > self > href

Example: Assume that you added the LDAP server ({ldapId} 1012) and common name, Sales-Americas, to IBM Spectrum Protect Plus.

A Python snippet that is similar to the following example can be used to return its {ldapUserHref} value, https://10.0.0.111/api/ldap/1012/user/Sales-Americas:

ldapId = "1012"
ldapCn = "Sales-Americas"

_response = requests.get('https://' + spp_ipv4 + '/api/ldap',
    headers={...}, verify=...)

_response_json = json.loads(_response.text)    # Convert to JSON

object_json = _response_json['users']

for keys in object_json:
    if keys['cn'] == ldapCn:
        object_href = keys['links']['self']['href']

print(object_href)
https://10.0.0.111/api/ldap/1012/user/Sales-Americas