当前位置: 首页>>代码示例>>Python>>正文


Python DSAdmin.createInstance方法代码示例

本文整理汇总了Python中dsadmin.DSAdmin.createInstance方法的典型用法代码示例。如果您正苦于以下问题:Python DSAdmin.createInstance方法的具体用法?Python DSAdmin.createInstance怎么用?Python DSAdmin.createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dsadmin.DSAdmin的用法示例。


在下文中一共展示了DSAdmin.createInstance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
    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"
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:winsyncmove.py

示例2:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:referint.py

示例3:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:replexpimp.py

示例4:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:31,代码来源:bug232910.py

示例5:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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
})
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:bug515329.py

示例6:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:34,代码来源:bug520151.py

示例7: MAY

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:groupsync.py

示例8: SimpleLDAPObject

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:32,代码来源:bug551198.py

示例9:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
    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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:32,代码来源:mrindexer.py

示例10:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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"
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:repl-many-be.py

示例11:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:nkinder,项目名称:scripts,代码行数:33,代码来源:mailsearch.py

示例12:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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)
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:33,代码来源:ticket-305.py

示例13: Entry

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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')
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:34,代码来源:pwsyntaxadduser.py

示例14:

# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import createInstance [as 别名]
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 = (
开发者ID:CACloudAdmin,项目名称:scripts,代码行数:34,代码来源:bugacihang.py


注:本文中的dsadmin.DSAdmin.createInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。