Skip to main content

A Python client library for the FusionDirectory API

Project description

fusiondirectory-api

A Python3 wrapper for the RPC API of LDAP manager FusionDirectory. You need to enable the plugin webservice in FusionDirectory to be able to use the API.

This wrapper supports the RPC based API in versions of FusionDirectory 1.3. This API may be deprecated in version 1.4 as a change to a REST based API is planned.

Installation

Install with pip: `pip3 install fusiondirectory-api"

Overview

A description of key concepts when working with the FusionDirectory API

Databases

FusionDirectory can handle more than a single database. In the GUI, the database to use can be selcted from a drop down. When the using the API, the name of the database to use, must be supplied when logging in.

Objects

FusionDirectory handles a number of objects. In general, the object type needs to be specified along with the object's DN when manipulating objects with the API.

The object types supported by an installation of FusionDirectory, depends on which plugins are enabled. The list of objects in an installation can be retrieved by calling list_types().

These are the objects in the FusionDirectory installation of the author of this project:

  • CONFIGURATION
  • OGROUP
  • PRINTER
  • ROLE
  • WORKSTATION
  • SAMBADOMAIN
  • USER
  • TERMINAL
  • SERVER
  • MOBILEPHONE
  • COUNTRY
  • ACLASSIGNMENT
  • ACLROLE
  • COMPONENT
  • GROUP
  • DCOBJECT
  • DEPARTMENT
  • DOMAIN
  • LOCALITY
  • ORGANIZATION
  • PHONE

Tabs

The data for an object, is organized in tabs. The tabs available for an object type, depends on the activated plugins. The tabs available for an object type can be retrieved by calling list_tabs(OBJECT_TYPE). By default, tabs are inactive. The following dictionary shows the avaiable tabs for the object type USER in the author's installation. The outher keys are the values which should be used when refering to a tab when using the API. The name is the name for the tab in the webinterface GUI.

{
  'user': {'name': 'User', 'active': True},
  'posixAccount': {'name': 'Unix', 'active': False},
  'personalInfo': {'name': 'Personal', 'active': False},
  'mailAccount': {'name': 'Mail', 'active': False},
  'sambaAccount': {'name': 'Samba', 'active': False},
  'userRoles': {'name': 'Groups and roles', 'active': False},
  'sshAccount': {'name': 'SSH', 'active': False},
  'userCertificates': {'name': 'Certificates', 'active': False},
  'reference': {'name': 'References', 'active': True},
  'ldapDump': {'name': 'LDAP', 'active': True}
}

Examples

This section contains som examples showing how to use the API.

Logging in

Log in, and show available object types.

# Import the library
from fusiondirectory_api import FusionDirectoryAPI

# Log in to the FusionDirectory server
api = FusionDirectoryAPI(
  host = "https://ldap.example.org",
  user = "user-name",
  password = "secret-password",
  database = "my-ldap",
  )

# Get the object types available
object_types = api.list_types()

# Print the object types
print(object_types)

Creating a new user

Let's create a new object of type USER. Its assumed you have created the object api as shown in the example above. Note, that the password is a list, because the inner workings are based on the GUI, where the user has to type password twice (To confirm).

# The data for the new user
values = {
  "user": {
    "uid": "bj",
    "sn": "Jacobsen",
    "givenName": "Bent",
    "userPassword": ["", "CzehlFp5WBLLULcCbuGOGrhy13fPajIL", "CzehlFp5WBLLULcCbuGOGrhy13fPajIL"],
  }
}

# Create the new user
new_user_dn = api.create_object("USER", values)

# Print the DN of the new user
print(f"Created new user: {new_user_dn}")

Updating a user

Add an email address to the user we created above.

# The data to add to the user
values = {
  "mailAccount": {
    "mail": "bj@example.org"
  }
}

# Update the user
updated_user_dn = api.update_object("USER", new_user_dn, values)

# Print to confirm the change
print(f"Updated data for user: {updated_user_dn}")

Deleting a user

Delete the user from the examples above.

# Delete the user
deleted_user_dn = api.delete_object("USER", new_user_dn)

# Print to confirm
print(f"Deleted user: {deleted_user_dn}")

Methods

The methods in the API. For now look in the code. All methods have doc strings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fusiondirectory-api-0.0.6.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

fusiondirectory_api-0.0.6-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file fusiondirectory-api-0.0.6.tar.gz.

File metadata

  • Download URL: fusiondirectory-api-0.0.6.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for fusiondirectory-api-0.0.6.tar.gz
Algorithm Hash digest
SHA256 a644b1d36703a5ce323b2e968fa105509e66e9613a8dfe5c86682cc862d26bfe
MD5 0e7718dfbf06bfe340ac0d3ac15c1580
BLAKE2b-256 2715ba4790dcaa1010c2f17eeea813e979ed461331d6acef494fa396826827cc

See more details on using hashes here.

File details

Details for the file fusiondirectory_api-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: fusiondirectory_api-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for fusiondirectory_api-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b7575d5c96e2a78d2492ebc5f168ccbd4f5a0bd8be6634af4122193c29ae2540
MD5 fe7fbec65c598353edf933c2d9e71132
BLAKE2b-256 24696a02262b9b5dbd8a444513146ecf52d4c776fbe0a9484996abea9eade162

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page