當前位置: 首頁>>代碼示例>>Python>>正文


Python dsadmin.DSAdmin類代碼示例

本文整理匯總了Python中dsadmin.DSAdmin的典型用法代碼示例。如果您正苦於以下問題:Python DSAdmin類的具體用法?Python DSAdmin怎麽用?Python DSAdmin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DSAdmin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup

def setup():
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(['o=mockbe2'])
    conn.added_replicas = []
    harn_nolog()
開發者ID:danielino,項目名稱:dsadmin,代碼行數:8,代碼來源:dsadmin_test.py

示例2: setup

def setup():
    # uses an existing 389 instance
    # add a suffix
    # add an agreement
    # This setup is quite verbose but to test dsadmin method we should
    # do things manually. A better solution would be to use an LDIF.
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(['o=mockbe1'])
    conn.added_replicas = []
    """  
開發者ID:danielino,項目名稱:dsadmin,代碼行數:13,代碼來源:config_test.py

示例3: setup

def setup():
    # uses an existing 389 instance
    # add a suffix
    # add an agreement
    # This setup is quite verbose but to test dsadmin method we should
    # do things manually. A better solution would be to use an LDIF.
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(["o=mockbe1"])
    conn.added_replicas = []

    # add a backend for testing ruv and agreements
    addbackend_harn(conn, "testReplica")

    # add another backend for testing replica.add()
    addbackend_harn(conn, "testReplicaCreation")
開發者ID:pudquick,項目名稱:dsadmin,代碼行數:18,代碼來源:backend_test.py

示例4: default_test

def default_test():
    host = 'localhost'
    port = 10200
    binddn = "cn=directory manager"
    bindpw = "password"
    suffix = 'dc=example,dc=com'
    basedn = DN_CONFIG
    scope = ldap.SCOPE_BASE
    filt = "(objectclass=*)"
    instance_name = ['m1', 'm2']

    instance_config = {
        'cfgdshost': host,
        'cfgdsport': port,
        'cfgdsuser': 'admin',
        'cfgdspwd': 'admin',
        'newrootpw': 'password',
        'newhost': host,
        'newport': port,
        'newinstance': instance_name[0],
        'newsuffix': suffix,
        'setup_admin': True,
    }
    try:
        m1 = DSAdmin(host, port, binddn, bindpw)
    except:
        m1 = DSAdminTools.createInstance(instance_config, verbose=1)
        added_instances.append(instance_config['newinstance'])

#        filename = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot, m1.inst)
#        m1.importLDIF(filename, "dc=example,dc=com", None, True)
#        m1.exportLDIF('/tmp/ldif', "dc=example,dc=com", False, True)
    print m1.sroot, m1.inst, m1.errlog
    ent = m1.getEntry(basedn, scope, filt, None)
    if ent:
        print ent.passwordmaxage
    instance_config.update({
                           'newinstance': instance_name[1],
                           'newport': port + 10,

                           })
    m1 = DSAdminTools.createInstance(instance_config, verbose=1)
    added_instances.append(instance_config['newinstance'])
#     m1.stop(True)
#     m1.start(True)
    cn = m1.setupBackend("dc=example2,dc=com")
    rc = m1.setupSuffix("dc=example2,dc=com", cn)
    entry = m1.getEntry(DN_CONFIG, ldap.SCOPE_SUBTREE, "(cn=" + cn + ")")
    print "new backend entry is:"
    print entry
    print entry.getValues('objectclass')
    print entry.OBJECTCLASS
    results = m1.search_s("cn=monitor", ldap.SCOPE_SUBTREE)
    print results
    results = m1.getBackendsForSuffix("dc=example,dc=com")
    print results

    print "done"
開發者ID:danielino,項目名稱:dsadmin,代碼行數:58,代碼來源:dsadmin_create_remove_test.py

示例5: handle

 def handle(self,dn,entry):
     """
     Append single record to dictionary of all records.
     """
     ent = Entry((dn, entry))
     normdn = DSAdmin.normalizeDN(dn)
     self.dndict[normdn] = ent
     cn = ent.cn
     if cn:
         self.cndict[cn] = ent
     self.dnlist.append(ent);
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:11,代碼來源:fixdnattrs.py

示例6: handle

 def handle(self,dn,entry):
     """
     assumes basedns[0] is the parent, basedns[1] already exists,
     and we want to create entries for basedns[2]
     """
     normdn = DSAdmin.normalizeDN(dn)
     for (basedn, ld) in self.iterlist:
         if normdn.endswith(basedn):
             ld.unparse(dn,entry)
             if basedn == self.basedns[1]:
                 dn = normdn.replace(basedn,self.basedns[2])
                 for (attr, vals) in entry.iteritems():
                     for ii in xrange(0, len(vals)):
                         vals[ii] = vals[ii].replace(basedn,self.basedns[2])
                 self.outldifs[2].unparse(dn,entry)
             break
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:16,代碼來源:replexpimp.py

示例7:

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,代碼行數:31,代碼來源:bug515329.py

示例8: DSAdmin

rootdn2 = rootdn1
rootpw1 = "password"
rootpw2 = rootpw1

basedn = "dc=testdomain, dc=com"

m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin(host1, port1, rootdn1, rootpw1)
m1.replicaSetupAll(m1replargs)

m2replargs = m1replargs
#os.environ['USE_DBX'] = 1
m2 = DSAdmin(host2, port2, rootdn2, rootpw2)
m2.replicaSetupAll(m2replargs)

print "create agreements and init consumers"
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
m1.startReplication_async(agmtm1tom2)
print "waiting for init to finish"
m1.waitForReplInit(agmtm1tom2)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)

nents = 5
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:31,代碼來源:bug509201.py

示例9:

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,代碼行數:29,代碼來源:bug232910.py

示例10:

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)

#m1.setLogLevel(65535)
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:31,代碼來源:bug297221.py

示例11:

#os.environ['USE_DBX'] = "1"
m1replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}

m1 = DSAdmin.createAndSetupReplica({
	'cfgdshost': host1,
	'cfgdsport': cfgport,
	'cfgdsuser': 'admin',
	'cfgdspwd': 'admin',
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True
}, m1replargs)
#del os.environ['USE_DBX']

m2replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:30,代碼來源:repladddel.py

示例12: DSAdmin

import os
import time
import ldap
from dsadmin import DSAdmin, Entry

host = "localhost.localdomain"
port = 10200

#os.environ['USE_DBX'] = "1"
#del os.environ['USE_DBX']

binddn = "cn=directory manager"
bindpw = "secret12"
conn = DSAdmin(host,port,binddn,bindpw)

suffix = "dc=example2,dc=com"
conn.addSuffix(suffix)

initfile = "/var/tmp/reftest.ldif"
conn.importLDIF(initfile, suffix, None, True)
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:20,代碼來源:srchreftest.py

示例13:

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,代碼行數:31,代碼來源:replexpimp.py

示例14:

m1replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log'   : True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': cfgport+10,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True,
    'no_admin': True
}, m1replargs
)
#del os.environ['USE_DBX']

m2replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica({
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:31,代碼來源:bug233642-3.py

示例15:

basedn = 'dc=example,dc=com'
replargs = {}
srvs = []
m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
os.environ['USE_GDB'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
    'no_admin': True
}, m1replargs
)
del os.environ['USE_GDB']
replargs[m1] = m1replargs
srvs.append(m1)

m2replargs = m1replargs
m2 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host2,
	'newport': port2,
	'newinst': 'm2',
	'newsuffix': basedn,
開發者ID:CACloudAdmin,項目名稱:scripts,代碼行數:31,代碼來源:bug507744.py


注:本文中的dsadmin.DSAdmin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。