ntf3.write(line) inf.close() ntf3.write(""" dn: cn=myobj,%s objectclass: person objectclass: myobjclass sn: me myattr: somelongvalue """ % basedn) ntf3.close() os.chmod(ntf3.name, 0644) srv = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'srv', 'newsuffix': basedn, 'verbose': False, 'no_admin': True, 'ConfigFile':[ntf.name], 'SchemaFile':[ntf2.name], 'InstallLdifFile':ntf3.name }) os.unlink(ntf.name) os.unlink(ntf2.name) srv.importLDIF(ntf3.name,basedn,'userRoot',True) #os.unlink(ntf3.name)
dn: cn=config changetype: modify replace: nsslapd-threadnumber nsslapd-threadnumber: 2 """) cfgfd.close() os.chmod(cfgfd.name, 0644) createargs['ConfigFile'] = [cfgfd.name] createargs['InstallLdifFile'] = 'none' #os.environ['USE_DBX'] = "1" #os.environ['USE_CALLGRIND'] = "1" print "create and setup m1" m1 = DSAdmin.createInstance(createargs) #del os.environ['USE_CALLGRIND'] #del os.environ['USE_DBX'] m2replargs = m1replargs createargs['newhost'] = host2 createargs['newport'] = port2 createargs['newinst'] = 'm2' #os.environ['USE_GDB'] = "1" print "create and setup m2" m2 = DSAdmin.createInstance(createargs) #del os.environ['USE_GDB'] os.unlink(cfgfd.name) print "add entries to each suffix"
configfile = [cfgfd.name] schemafile = ['/share/freeipa/freeipa/install/share/60ipaconfig.ldif', '/share/freeipa/freeipa/install/share/60kerberos.ldif'] # '/share/freeipa/freeipa/install/share/60radius.ldif'] else: configfile = [] schemafile = [] cfgfd = None os.environ['USE_GDB'] = "1" ds = DSAdmin.createInstance({ 'newrootpw': rootpw1, 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': suffix, 'verbose': False, 'no_admin': True, 'ConfigFile': configfile, 'SchemaFile': schemafile }) if cfgfd: os.unlink(cfgfd.name) ds.setupSSL(secport1) ds.replicaSetupAll(replargs) if ipawinsync: print "Enable the memberof plugin . . ." dn = "cn=MemberOf Plugin,cn=plugins,cn=config"
from dirsyncctrl import DirSyncCtrl host1 = "vmhost.testdomain.com" port1 = 1200 secport1 = port1+1 rootdn = "cn=directory manager" rootpw = "password" basedn = 'dc=example,dc=com' newinst = 'ds' os.environ['USE_VALGRIND'] = "1" srv = DSAdmin.createInstance({ 'newrootpw': rootpw, 'newhost': host1, 'newport': port1, 'newinst': newinst, 'newsuffix': basedn, 'no_admin': True }) print "turn on syntax checking and trivial words checking" attr = "passwordCheckSyntax" mod = [(ldap.MOD_REPLACE, attr, "on")] srv.modify_s("cn=config", mod) print "add a user with a password" dn = "uid=scarter,dc=example,dc=com" bindpw = "SPrain12" ent = Entry(dn) ent.setValues('objectclass', 'inetOrgPerson') ent.setValues('cn', 'Sam Carter')
nsslapd-pluginType: betxnpostoperation dn: %s changetype: modify replace: nsslapd-db-logbuf-size nsslapd-db-logbuf-size: 10000000 """ % (dn1, dn2)) cfgfd.close() os.chmod(cfgfd.name, 0644) #os.environ['USE_VALGRIND'] = '1' ds = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': basedn, 'no_admin': True, 'ConfigFile': [cfgfd.name] }) os.unlink(cfgfd.name) initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot,ds.inst) else: initfilesrc = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr') initfile = "%s/var/lib/dirsrv/slapd-%s/ldif/Example.ldif" % (os.environ.get('PREFIX', ''), 'ds') shutil.copy(initfilesrc, initfile) print "importing database" ds.importLDIF(initfile, '', "userRoot", False)
m1replargs = { 'suffix': basedn, 'bename': "userRoot", 'binddn': "cn=replrepl,cn=config", 'bindcn': "replrepl", 'bindpw': "replrepl", 'log': False } m2replargs = m1replargs os.environ['USE_VALGRIND'] = "1" m1 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'm1', 'newsuffix': basedn, 'verbose': False, 'no_admin': True }) del os.environ['USE_VALGRIND'] m2 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host2, 'newport': port2, 'newinst': 'm2', 'newsuffix': basedn, 'verbose': False, 'no_admin': True })
'/share/freeipa/freeipa/install/share/60ipaconfig.ldif', '/share/freeipa/freeipa/install/share/60kerberos.ldif' ] # '/share/freeipa/freeipa/install/share/60radius.ldif'] else: configfile = [] schemafile = [] cfgfd = None os.environ['USE_GDB'] = "1" ds = DSAdmin.createInstance({ 'newrootpw': rootpw1, 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': suffix, 'verbose': False, 'no_admin': True, 'ConfigFile': configfile, 'SchemaFile': schemafile }) if cfgfd: os.unlink(cfgfd.name) ds.setupSSL(secport1) ds.replicaSetupAll(replargs) if ipawinsync: print "Enable the memberof plugin . . ." dn = "cn=MemberOf Plugin,cn=plugins,cn=config"
import os import ldap from dsadmin import DSAdmin, Entry host1 = "localhost.localdomain" host2 = host1 cfgport = 1100 port1 = cfgport + 30 port2 = port1 + 10 #os.environ['USE_DBX'] = "1" m1 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'm1', 'newsuffix': 'dc=example,dc=com', 'verbose': True, 'no_admin': True }) #del os.environ['USE_DBX'] initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst) else: initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr') m1.importLDIF(initfile, '', "userRoot", True)
import os import ldap from dsadmin import DSAdmin, Entry host1 = "localhost.localdomain" host2 = host1 cfgport = 1100 port1 = cfgport + 30 port2 = port1 + 10 #os.environ['USE_DBX'] = "1" m1 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'm1', 'newsuffix': 'dc=example,dc=com', 'verbose': True, 'no_admin': True }) #del os.environ['USE_DBX'] initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot, m1.inst) else: initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get( 'PREFIX', '/usr') m1.importLDIF(initfile, '', "userRoot", True)
import time import ldap import ldif import tempfile from dsadmin import DSAdmin, Entry host1 = "localhost.localdomain" port1 = 1110 basedn = "dc=example,dc=com" os.environ["USE_GDB"] = "1" srv = DSAdmin.createInstance( { "newrootpw": "password", "newhost": host1, "newport": port1, "newinst": "srv", "newsuffix": basedn, "no_admin": True, } ) del os.environ["USE_GDB"] initfile = "" if os.environ.has_key("SERVER_ROOT"): initfile = "%s/slapd-%s/ldif/Example.ldif" % (srv.sroot, srv.inst) else: initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get("PREFIX", "/usr") print "import the ldif file" srv.importLDIF(initfile, "", "userRoot", True)
from dsadmin import DSAdmin, Entry, LEAF_TYPE host1 = "localhost.localdomain" host2 = host1 port1 = 1130 port2 = port1 + 10 rootdn1 = "cn=directory manager" rootpw1 = 'password' rootdn2 = rootdn1 rootpw2 = rootpw1 suffix = "dc=example,dc=com" mux = DSAdmin.createInstance({ 'newrootpw': rootpw1, 'newhost': host1, 'newport': port1, 'newinst': 'mux', 'newsuffix': 'dc=notused', 'no_admin': True }) os.environ['USE_GDB'] = "1" farm = DSAdmin.createInstance({ 'newrootpw': rootpw2, 'newhost': host2, 'newport': port2, 'newinst': 'farm', 'newsuffix': 'dc=notused', 'no_admin': True }) # add the suffix
host2 = host1 port1 = 1389 port2 = port1+10 basedn = "dc=example,dc=com" createargs = { 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': basedn, 'no_admin': True } os.environ['USE_VALGRIND'] = "1" ds = DSAdmin.createInstance(createargs) del os.environ['USE_VALGRIND'] initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot,ds.inst) else: initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr') ds.importLDIF(initfile, '', "userRoot", True) userdn = "uid=scarter,ou=people," + basedn userpw = "sprain" print "Allow local password policy" p = {'nsslapd-pwpolicy-local':'on'} ds.setPwdPolicy(p)
host2 = host1 port1 = 1389 port2 = port1 + 10 basedn = "dc=example,dc=com" createargs = { 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': basedn, 'no_admin': True } os.environ['USE_VALGRIND'] = "1" ds = DSAdmin.createInstance(createargs) del os.environ['USE_VALGRIND'] initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot, ds.inst) else: initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get( 'PREFIX', '/usr') ds.importLDIF(initfile, '', "userRoot", True) userdn = "uid=scarter,ou=people," + basedn userpw = "sprain" print "Allow local password policy" p = {'nsslapd-pwpolicy-local': 'on'}
from dsadmin import DSAdmin, Entry, LEAF_TYPE host1 = "localhost.localdomain" host2 = host1 port1 = 1130 port2 = port1+10 rootdn1 = "cn=directory manager" rootpw1 = 'password' rootdn2 = rootdn1 rootpw2 = rootpw1 suffix = "dc=example,dc=com" mux = DSAdmin.createInstance({ 'newrootpw': rootpw1, 'newhost': host1, 'newport': port1, 'newinst': 'mux', 'newsuffix': 'dc=notused', 'no_admin': True }) os.environ['USE_GDB'] = "1" farm = DSAdmin.createInstance({ 'newrootpw': rootpw2, 'newhost': host2, 'newport': port2, 'newinst': 'farm', 'newsuffix': 'dc=notused', 'no_admin': True }) # add the suffix
ntf3.write(line) inf.close() ntf3.write(""" dn: cn=myobj,%s objectclass: person objectclass: myobjclass sn: me myattr: somelongvalue """ % basedn) ntf3.close() os.chmod(ntf3.name, 0644) srv = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'srv', 'newsuffix': basedn, 'verbose': False, 'no_admin': True, 'ConfigFile': [ntf.name], 'SchemaFile': [ntf2.name], 'InstallLdifFile': ntf3.name }) os.unlink(ntf.name) os.unlink(ntf2.name) srv.importLDIF(ntf3.name, basedn, 'userRoot', True) #os.unlink(ntf3.name)
if ipawinsync: print "Enable the memberof plugin . . ." dn = "cn=MemberOf Plugin,cn=plugins,cn=config" mod = [(ldap.MOD_REPLACE, 'nsslapd-pluginenabled', 'on')] ds.modify_s(dn, mod) ds.stop() ds.start() ds.importLDIF(ipainit, suffix) if useds: ad = DSAdmin.createInstance({ 'newrootpw': rootpw2, 'newhost': host2, 'newport': port2, 'newinst': 'ad', 'newsuffix': suffix, 'verbose': False, 'no_admin': True }) print "Fake AD needs extra schema . . ." oidnum = 10000000 ad.addAttr("( 2.16.840.1.113730.3.1.%d NAME 'samAccountName' DESC 'AD uid attribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )" % oidnum) oidnum = oidnum + 1 ad.addAttr("( 2.16.840.1.113730.3.1.%d NAME 'objectGUID' DESC 'AD uuid attribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE )" % oidnum) oidnum = oidnum + 1 ad.addAttr("( 2.16.840.1.113730.3.1.%d NAME 'userAccountControl' DESC 'AD user account control' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )" % oidnum) oidnum = oidnum + 1 ad.addObjClass("( 2.16.840.1.113730.3.2.%d NAME 'adPerson' DESC 'AD person mixin' SUP top AUXILIARY MAY ( samAccountName $ objectGUID $ name $ userAccountControl ) )" % oidnum) oidnum = oidnum + 1 ad.addAttr("( 2.16.840.1.113730.3.1.%d NAME 'groupType' DESC 'AD group type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' )" % oidnum)
changetype: modify replace: nsslapd-threadnumber nsslapd-threadnumber: 2 """ ) cfgfd.close() os.chmod(cfgfd.name, 0644) createargs["ConfigFile"] = [cfgfd.name] createargs["InstallLdifFile"] = "none" # os.environ['USE_DBX'] = "1" # os.environ['USE_CALLGRIND'] = "1" print "create and setup m1" m1 = DSAdmin.createInstance(createargs) # del os.environ['USE_CALLGRIND'] # del os.environ['USE_DBX'] m2replargs = m1replargs createargs["newhost"] = host2 createargs["newport"] = port2 createargs["newinst"] = "m2" # os.environ['USE_GDB'] = "1" print "create and setup m2" m2 = DSAdmin.createInstance(createargs) # del os.environ['USE_GDB'] os.unlink(cfgfd.name) print "add entries to each suffix"
m1replargs = { 'suffix': basedn, 'bename': "userRoot", 'binddn': "cn=replrepl,cn=config", 'bindcn': "replrepl", 'bindpw': "replrepl", 'pd': 5, 'log' : False } m2replargs = m1replargs m1 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'm1', 'newsuffix': basedn, 'verbose': True, 'no_admin': True }) #os.environ['USE_GDB'] = "1" m2 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host2, 'newport': port2, 'newinst': 'm2', 'newsuffix': basedn, 'verbose': False, 'no_admin': True })
import ldap from dsadmin import DSAdmin, Entry, LEAF_TYPE from ldap.controls import SimplePagedResultsControl print "start" host1 = "localhost.localdomain" port1 = 1389 basedn = "dc=example,dc=com" dom = 'example.com' dnsdom = 'localdomain' #os.environ['USE_VALGRIND'] = '1' ds = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': basedn, 'no_admin': True }) initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot, ds.inst) else: initfilesrc = "%s/share/dirsrv/data/Example.ldif" % os.environ.get( 'PREFIX', '/usr') initfile = "%s/var/lib/dirsrv/slapd-%s/ldif/Example.ldif" % ( os.environ.get('PREFIX', ''), 'ds') shutil.copy(initfilesrc, initfile) print "importing database" ds.importLDIF(initfile, '', "userRoot", False)
from dsadmin import DSAdmin, Entry from ldap.ldapobject import SimpleLDAPObject import pprint host1 = "localhost.localdomain" port1 = 1110 basedn = 'dc=example,dc=com' ldapifilepath = os.environ.get('PREFIX', "") + "/var/run/slapd-srv.socket" os.environ['USE_GDB'] = "1" srv = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'srv', 'newsuffix': basedn, 'no_admin': True, 'ldapifilepath': ldapifilepath }) del os.environ['USE_GDB'] ldapiurl = ldapurl.LDAPUrl(None, "ldapi", ldapifilepath) conn = SimpleLDAPObject(ldapiurl.initializeUrl()) print "connecting to", ldapiurl.initializeUrl() conn.simple_bind_s("cn=directory manager", "password") ents = conn.search_s("", ldap.SCOPE_BASE) pprint.pprint(ents)
import os import sys import time import ldap import ldif from dsadmin import DSAdmin, Entry host1 = "localhost.localdomain" port1 = 1200 basedn = "dc=example,dc=com" srv = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'srv', 'newsuffix': basedn, 'verbose': False, 'no_admin': True }) basedns = [basedn] benames = ['userRoot'] base1 = "ou=people," + basedn basedns.append(base1) srv.addSuffix(base1) ents = srv.getBackendsForSuffix(base1, ['cn']) benames.append(ents[0].cn) base2 = "ou=people1," + basedn basedns.append(base2) srv.addSuffix(base2)
host2 = host1 port1 = 1200 port2 = port1 + 10 secport1 = port1 + 1 secport2 = port2 + 1 basedn = 'dc=example,dc=com' #os.environ['USE_VALGRIND'] = "1" m1 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'm1', 'newsuffix': basedn, 'no_admin': True, 'InstallLdifFile': os.environ.get('PREFIX', '/usr') + "/share/dirsrv/data/Example.ldif" }) #del os.environ['USE_VALGRIND'] #os.environ['USE_VALGRIND'] = "1" m2 = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host2, 'newport': port2, 'newinst': 'm2',
from dirsyncctrl import DirSyncCtrl host1 = "vmhost.testdomain.com" port1 = 1200 secport1 = port1 + 1 rootdn = "cn=directory manager" rootpw = "password" basedn = 'dc=example,dc=com' newinst = 'ds' os.environ['USE_VALGRIND'] = "1" srv = DSAdmin.createInstance({ 'newrootpw': rootpw, 'newhost': host1, 'newport': port1, 'newinst': newinst, 'newsuffix': basedn, 'no_admin': True }) print "turn on syntax checking and trivial words checking" attr = "passwordCheckSyntax" mod = [(ldap.MOD_REPLACE, attr, "on")] srv.modify_s("cn=config", mod) print "add a user with a password" dn = "uid=scarter,dc=example,dc=com" bindpw = "SPrain12" ent = Entry(dn) ent.setValues('objectclass', 'inetOrgPerson') ent.setValues('cn', 'Sam Carter')
import ldap from dsadmin import DSAdmin, Entry, LEAF_TYPE from ldap.controls import SimplePagedResultsControl print "start" host1 = "localhost.localdomain" port1 = 1389 basedn = "dc=example,dc=com" dom = 'example.com' dnsdom = 'localdomain' #os.environ['USE_VALGRIND'] = '1' ds = DSAdmin.createInstance({ 'newrootpw': 'password', 'newhost': host1, 'newport': port1, 'newinst': 'ds', 'newsuffix': basedn, 'no_admin': True }) initfile = '' if os.environ.has_key('SERVER_ROOT'): initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot,ds.inst) else: initfilesrc = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr') initfile = "%s/var/lib/dirsrv/slapd-%s/ldif/Example.ldif" % (os.environ.get('PREFIX', ''), 'ds') shutil.copy(initfilesrc, initfile) print "importing database" ds.importLDIF(initfile, '', "userRoot", False) dn2aci = (