Skip to main content

LDAP Server Profile

The LdapServerProfile service manages LDAP server profile objects in Strata Cloud Manager, defining LDAP directory servers used for user authentication and group lookups.

Class Overview

The LdapServerProfile class provides CRUD operations for LDAP server profile objects. It is accessed through the client.ldap_server_profile attribute on an initialized Scm instance.

from scm.client import Scm

client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

# Access the LdapServerProfile service
ldap_profiles = client.ldap_server_profile

Key Attributes

AttributeTypeRequiredDescription
namestrYesProfile name
idUUIDYes*Unique identifier (*response only)
serverList[LdapServer]NoList of LDAP servers
basestrNoBase distinguished name (max 255 chars)
bind_dnstrNoBind distinguished name (max 255 chars)
bind_passwordstrNoBind password (max 121 chars)
bind_timelimitstrNoBind time limit
ldap_typeLdapTypeNoLDAP server type
retry_intervalintNoRetry interval in seconds
sslboolNoEnable SSL
timelimitintNoTime limit in seconds
verify_server_certificateboolNoVerify server certificate
folderstrNo*Folder location
snippetstrNo*Snippet location
devicestrNo*Device location

* Exactly one of folder, snippet, or device is required.

Methods

List LDAP Server Profiles

Retrieves a list of LDAP server profile objects with optional filtering.

# List all LDAP server profiles in a folder
profiles = client.ldap_server_profile.list(folder="Texas")

for profile in profiles:
print(f"Name: {profile.name}, Type: {profile.ldap_type}")

Parameters:

ParameterTypeRequiredDescription
folderstrNo*Folder in which the resource is defined
snippetstrNo*Snippet in which the resource is defined
devicestrNo*Device in which the resource is defined
exact_matchboolNoOnly return objects exactly in the container
exclude_foldersList[str]NoList of folders to exclude
exclude_snippetsList[str]NoList of snippets to exclude
exclude_devicesList[str]NoList of devices to exclude

* Exactly one of folder, snippet, or device is required.

Fetch an LDAP Server Profile

Retrieves a single LDAP server profile by name and container.

# Fetch a specific LDAP server profile by name
profile = client.ldap_server_profile.fetch(
name="corp-ldap",
folder="Texas"
)

print(f"Name: {profile.name}, Base DN: {profile.base}")

Parameters:

ParameterTypeRequiredDescription
namestrYesThe name of the LDAP server profile
folderstrNo*Folder in which the resource is defined
snippetstrNo*Snippet in which the resource is defined
devicestrNo*Device in which the resource is defined

* Exactly one of folder, snippet, or device is required.

Create an LDAP Server Profile

Creates a new LDAP server profile object.

# Create a new LDAP server profile
profile = client.ldap_server_profile.create({
"name": "corp-ldap",
"folder": "Texas",
"server": [
{
"name": "ldap-primary",
"address": "ldap.example.com",
"port": 389
}
],
"base": "dc=example,dc=com",
"bind_dn": "cn=admin,dc=example,dc=com",
"bind_password": "admin-password",
"ldap_type": "active-directory",
"ssl": True
})

print(f"Created profile: {profile.name} (ID: {profile.id})")

Parameters:

ParameterTypeRequiredDescription
dataDict[str, Any]YesDictionary containing the profile configuration

Update an LDAP Server Profile

Updates an existing LDAP server profile object.

# Fetch, modify, update
profile = client.ldap_server_profile.fetch(name="corp-ldap", folder="Texas")
profile.ssl = True
profile.verify_server_certificate = True
updated = client.ldap_server_profile.update(profile)

print(f"Updated profile: {updated.name}")

Delete an LDAP Server Profile

Deletes an LDAP server profile object by ID.

# Delete by ID
client.ldap_server_profile.delete("abcd1234-5678-9abc-def0-123456789abc")

Parameters:

ParameterTypeRequiredDescription
object_idstrYesThe UUID of the profile to delete

Use Cases

Active Directory Integration

# Create an LDAP profile for Active Directory
profile = client.ldap_server_profile.create({
"name": "ad-integration",
"folder": "Texas",
"server": [
{
"name": "dc-primary",
"address": "dc1.example.com",
"port": 636
},
{
"name": "dc-secondary",
"address": "dc2.example.com",
"port": 636
}
],
"base": "dc=example,dc=com",
"bind_dn": "cn=svc-firewall,ou=services,dc=example,dc=com",
"bind_password": "service-password",
"ldap_type": "active-directory",
"ssl": True,
"verify_server_certificate": True,
"timelimit": 30,
"bind_timelimit": "30"
})

Audit LDAP Configurations

# List and audit all LDAP profiles for SSL compliance
profiles = client.ldap_server_profile.list(
folder="Texas",
exact_match=True
)

for profile in profiles:
ssl_status = "Enabled" if profile.ssl else "Disabled"
print(f"Profile: {profile.name}, SSL: {ssl_status}")

Error Handling

from scm.exceptions import InvalidObjectError, MissingQueryParameterError

try:
profile = client.ldap_server_profile.fetch(
name="corp-ldap",
folder="Texas"
)
except MissingQueryParameterError as e:
print(f"Missing parameter: {e.message}")
except InvalidObjectError as e:
print(f"Invalid object: {e.message}")
except Exception as e:
print(f"Unexpected error: {e}")