OPSI.Backend.LDAP module

opsi python library - LDAP

This module is part of the desktop management solution opsi (open pc server integration) http://www.opsi.org

Copyright (C) 2013-2014 uib GmbH

http://www.uib.de/

All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

@copyright: uib GmbH <info@uib.de> @author: Jan Schneider <j.schneider@uib.de> @author: Erol Ueluekmen <e.ueluekmen@uib.de> @author: Niko Wenselowski <n.wenselowski@uib.de> @license: GNU Affero GPL version 3

class OPSI.Backend.LDAP.LDAPBackend(**kwargs)

Bases: OPSI.Backend.Backend.ConfigDataBackend

backend_createBase()
backend_deleteBase()
backend_exit()
configState_deleteObjects(configStates)
configState_getObjects(attributes=[], **filter)
configState_insertObject(configState)
configState_updateObject(configState)
config_deleteObjects(configs)
config_getObjects(attributes=[], **filter)
config_insertObject(config)
config_updateObject(config)
group_deleteObjects(groups)
group_getObjects(attributes=[], **filter)
group_insertObject(group)
group_updateObject(group)
host_deleteObjects(hosts)
host_getObjects(attributes=[], **filter)
host_insertObject(host)
host_updateObject(host)
objectToGroup_deleteObjects(objectToGroups)
objectToGroup_getObjects(attributes=[], **filter)
objectToGroup_insertObject(objectToGroup)
objectToGroup_updateObject(objectToGroup)
productDependency_deleteObjects(productDependencies)
productDependency_getObjects(attributes=[], **filter)
productDependency_insertObject(productDependency)
productDependency_updateObject(productDependency)
productOnClient_deleteObjects(productOnClients)
productOnClient_getObjects(attributes=[], **filter)
productOnClient_insertObject(productOnClient)
productOnClient_updateObject(productOnClient)
productOnDepot_deleteObjects(productOnDepots)
productOnDepot_getObjects(attributes=[], **filter)
productOnDepot_insertObject(productOnDepot)
productOnDepot_updateObject(productOnDepot)
productPropertyState_deleteObjects(productPropertyStates)
productPropertyState_getObjects(attributes=[], **filter)
productPropertyState_insertObject(productPropertyState)
productPropertyState_updateObject(productPropertyState)
productProperty_deleteObjects(productProperties)
productProperty_getObjects(attributes=[], **filter)
productProperty_insertObject(productProperty)
productProperty_updateObject(productProperty)
product_deleteObjects(products)
product_getObjects(attributes=[], **filter)
product_insertObject(product)
product_updateObject(product)
class OPSI.Backend.LDAP.LDAPObject(dn)

This class handles ldap objects.

addAttributeValue(attribute, value)

Add a value to an object’s attribute.

addObjectClass(objectClass)
deleteAttributeValue(attribute, value)

Delete a value from the list of attribute values.

deleteFromDirectory(ldapSession, recursive=False)
exists(ldapSession)
getAttribute(attribute, default='DEFAULT_UNDEFINED', valuesAsList=False)

Get a specific attribute from object. Set valuesAsList to a boolean true value to get a list, even if there is only one attribute value.

getAttributeDict(valuesAsList=False)

Get all attributes of object as dict. All values in self._new are lists by default, a list of length 0 becomes the value None if there is only one item the item’s value is used

getCn()
getContainer()
getContainerCn()
getDn()
getObjectClasses()
getParent()
getRdn()
new(*objectClasses, **attributes)
readFromDirectory(ldapSession, *attributes)

If no attributes are given, all attributes are read. If attributes are specified for read speedup, the object can NOT be written back to ldap!

removeObjectClass(objectClass)
setAttribute(attribute, value)
writeToDirectory(ldapSession)

Writes the object to the ldap tree.

class OPSI.Backend.LDAP.LDAPObjectSearch(ldapSession, baseDn='', scope=2, filter=u'(ObjectClass=*)')

This class simplifies object searchs.

getCn()

Returns the cn of the first object found.

getCns()

Returns the cns of all objects found.

getDn()

Returns the dn of the first object found.

getDns()

Returns the dns of all objects found.

getLDAPObject()

Returns the first object found as Object instance.

getObjects()

Returns all objects as Object instances.

class OPSI.Backend.LDAP.LDAPSession(**kwargs)

This class handles the requests to a ldap server

addByModlist(dn, new)

This function is used to add an object to the ldap directory.

connect()

Connect to a ldap server.

delete(dn)

This function is used to delete an object in a ldap directory.

disconnect()

Disconnect from ldap server

getAddCount()

Get number of all add commands (requests) sent to ldap server.

getCommandCount()

Get number of all commands (requests) sent to ldap server.

getCommandStatistics()

Get number of all commands as dict.

getDeleteCount()

Get number of all delete commands (requests) sent to ldap server.

getModifyCount()

Get number of all modify commands (requests) sent to ldap server.

getSearchCount()

Get number of all search commands (requests) sent to ldap server.

modifyByModlist(dn, old, new)

This function is used to modify an object in a ldap directory.

search(baseDn, scope, filter, attributes)

This function is used to search in a ldap directory.