Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to read the schema of your ldap server. </p> <p>This code may work for you, as tempalte </p> <pre><code>#!/usr/bin/env python #coding:utf-8 # Author: peter --&lt;pjl@hpc.com.py&gt; # Purpose: Tareas comunes a utilizar con respecto a schemas ldap # Created: 01/05/12 import ldap import ldap.schema ######################################################################## class SchemasIPA(object): __ldaps = ldap.schema #---------------------------------------------------------------------- def __init__(self, url): """Constructor""" ldap._trace_level = 0 ldap.set_option(ldap.OPT_DEBUG_LEVEL,0) subschemasubentry_dn, self.schema = ldap.schema.urlfetch(url,ldap._trace_level) self.oc_tree = self.schema.tree(ldap.schema.ObjectClass) self.at_tree = self.schema.tree(ldap.schema.AttributeType) def getobjectclasses(self): """ trae la listas de objectclasses de un servidor dado """ allobjc = {} for a in self.oc_tree.keys(): objc = self.schema.get_obj(ldap.schema.ObjectClass, a) if objc != None: allobjc[objc.oid] = (objc.names, objc.must, objc.may, objc.sup, objc.obsolete) return allobjc def getatributes(self): """ trae la lista de atributos de un servidor dado """ allatt= {} o = [] for a in self.at_tree.keys(): att = self.schema.get_obj(ldap.schema.AttributeType, a) if att != None: allatt[att.oid] = (att.names, att.syntax, att.syntax_len, att.desc, att.collective, att.equality, att.single_value) return allatt def getvalidoid(self, objects): """ retorno un valor oid libre valida para la creacion de esquemas y atributos el proceso valido es pedirle a la iana un oid valido, pero se tarda mas de un mes los oid a utilizar son valores predefinidos al momento de la instalacion del servidor ldap """ pass if __name__ == '__main__': sch = SchemasIPA('ldap://localhost') #at = sch.getatributes() ob = sch.getobjectclasses() for a, b in ob.iteritems(): print a print b[0] </code></pre> <p>Then you can wrapper this class like this</p> <pre><code>#a file contained the above class import schemas olschemas = schemas.SchemasIPA(url='ldap://192.168.1.81') #here are, some magic :) pa = olschemas.schema.get_obj(olschemas._SchemasIPA__ldaps.ObjectClass, 'posixaccount') pa.must #going to print all the attributes that can't be null's pa.may #going to print all the attributes that are optional's </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload