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


Python Schema.linked_attributes方法代码示例

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


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

示例1: FDSBackend

# 需要导入模块: from schema import Schema [as 别名]
# 或者: from schema.Schema import linked_attributes [as 别名]
class FDSBackend(LDAPBackend):
    def __init__(self, backend_type, paths=None, setup_path=None, lp=None, credentials=None,
                 names=None, message=None,
                 domainsid=None,
                 schema=None,
                 hostname=None,
                 ldapadminpass=None,
                 slapd_path=None,
                 ldap_backend_extra_port=None,
                 ldap_dryrun_mode=False,
                 root=None,
                 setup_ds_path=None):

        super(FDSBackend, self).__init__(
                backend_type=backend_type,
                paths=paths, setup_path=setup_path,
                lp=lp, credentials=credentials,
                names=names,
                message=message,
                domainsid=domainsid,
                schema=schema,
                hostname=hostname,
                ldapadminpass=ldapadminpass,
                slapd_path=slapd_path,
                ldap_backend_extra_port=ldap_backend_extra_port,
                ldap_dryrun_mode=ldap_dryrun_mode)

        self.root = root
        self.setup_ds_path = setup_ds_path

        self.sambadn = "CN=Samba"

        self.fedoradsinf = os.path.join(paths.ldapdir, "fedorads.inf")
        self.partitions_ldif = os.path.join(paths.ldapdir, "fedorads-partitions.ldif")
        self.sasl_ldif = os.path.join(paths.ldapdir, "fedorads-sasl.ldif")
        self.dna_ldif = os.path.join(paths.ldapdir, "fedorads-dna.ldif")
        self.pam_ldif = os.path.join(paths.ldapdir, "fedorads-pam.ldif")
        self.refint_ldif = os.path.join(paths.ldapdir, "fedorads-refint.ldif")
        self.linked_attrs_ldif = os.path.join(paths.ldapdir, "fedorads-linked-attributes.ldif")
        self.index_ldif = os.path.join(paths.ldapdir, "fedorads-index.ldif")
        self.samba_ldif = os.path.join(paths.ldapdir, "fedorads-samba.ldif")

        self.samba3_schema = self.setup_path("../../examples/LDAP/samba.schema")
        self.samba3_ldif = os.path.join(self.paths.ldapdir, "samba3.ldif")

        self.retcode = subprocess.call(["bin/oLschema2ldif", "-H", "NONE",
                "-I", self.samba3_schema,
                "-O", self.samba3_ldif,
                "-b", self.names.domaindn],
                close_fds=True, shell=False)

        if self.retcode != 0:
            raise Exception("Unable to convert Samba 3 schema.")

        self.schema = Schema(
                self.setup_path,
                self.domainsid,
                schemadn=self.names.schemadn,
                serverdn=self.names.serverdn,
                files=[setup_path("schema_samba4.ldif"), self.samba3_ldif],
                prefixmap=["1000:1.3.6.1.4.1.7165.2.1", "1001:1.3.6.1.4.1.7165.2.2"])

    def provision(self):
        if self.ldap_backend_extra_port is not None:
            serverport = "ServerPort=%d" % self.ldap_backend_extra_port
        else:
            serverport = ""
        
        setup_file(self.setup_path("fedorads.inf"), self.fedoradsinf, 
                   {"ROOT": self.root,
                    "HOSTNAME": self.hostname,
                    "DNSDOMAIN": self.names.dnsdomain,
                    "LDAPDIR": self.paths.ldapdir,
                    "DOMAINDN": self.names.domaindn,
                    "LDAPMANAGERDN": self.names.ldapmanagerdn,
                    "LDAPMANAGERPASS": self.ldapadminpass, 
                    "SERVERPORT": serverport})

        setup_file(self.setup_path("fedorads-partitions.ldif"), self.partitions_ldif, 
                   {"CONFIGDN": self.names.configdn,
                    "SCHEMADN": self.names.schemadn,
                    "SAMBADN": self.sambadn,
                    })

        setup_file(self.setup_path("fedorads-sasl.ldif"), self.sasl_ldif, 
                   {"SAMBADN": self.sambadn,
                    })

        setup_file(self.setup_path("fedorads-dna.ldif"), self.dna_ldif, 
                   {"DOMAINDN": self.names.domaindn,
                    "SAMBADN": self.sambadn,
                    "DOMAINSID": str(self.domainsid),
                    })

        setup_file(self.setup_path("fedorads-pam.ldif"), self.pam_ldif)

        lnkattr = self.schema.linked_attributes()

        refint_config = data = open(self.setup_path("fedorads-refint-delete.ldif"), 'r').read()
        memberof_config = ""
#.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:103,代码来源:provisionbackend.py

示例2: OpenLDAPBackend

# 需要导入模块: from schema import Schema [as 别名]
# 或者: from schema.Schema import linked_attributes [as 别名]
class OpenLDAPBackend(LDAPBackend):
    def __init__(self, backend_type, paths=None, setup_path=None, lp=None, credentials=None,
                 names=None, message=None,
                 domainsid=None,
                 schema=None,
                 hostname=None,
                 ldapadminpass=None,
                 slapd_path=None,
                 ldap_backend_extra_port=None,
                 ldap_dryrun_mode=False,
                 ol_mmr_urls=None,
                 nosync=False):

        super(OpenLDAPBackend, self).__init__(
                backend_type=backend_type,
                paths=paths, setup_path=setup_path,
                lp=lp, credentials=credentials,
                names=names,
                message=message,
                domainsid=domainsid,
                schema=schema,
                hostname=hostname,
                ldapadminpass=ldapadminpass,
                slapd_path=slapd_path,
                ldap_backend_extra_port=ldap_backend_extra_port,
                ldap_dryrun_mode=ldap_dryrun_mode)

        self.ol_mmr_urls = ol_mmr_urls
        self.nosync = nosync

        self.schema = Schema(
                self.setup_path,
                self.domainsid,
                schemadn=self.names.schemadn,
                serverdn=self.names.serverdn,
                files=[setup_path("schema_samba4.ldif")]);

    def provision(self):
        # Wipe the directories so we can start
        shutil.rmtree(os.path.join(self.paths.ldapdir, "db"), True)

        #Allow the test scripts to turn off fsync() for OpenLDAP as for TDB and LDB
        nosync_config = ""
        if self.nosync:
            nosync_config = "dbnosync"
        
        lnkattr = self.schema.linked_attributes()
        refint_attributes = ""
        memberof_config = "# Generated from Samba4 schema\n"
        for att in  lnkattr.keys():
            if lnkattr[att] is not None:
                refint_attributes = refint_attributes + " " + att 
            
                memberof_config += read_and_sub_file(self.setup_path("memberof.conf"),
                                                 { "MEMBER_ATTR" : att ,
                                                   "MEMBEROF_ATTR" : lnkattr[att] })
            
        refint_config = read_and_sub_file(self.setup_path("refint.conf"),
                                      { "LINK_ATTRS" : refint_attributes})
    
        attrs = ["linkID", "lDAPDisplayName"]
        res = self.schema.ldb.search(expression="(&(objectclass=attributeSchema)(searchFlags:1.2.840.113556.1.4.803:=1))", base=self.names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
        index_config = ""
        for i in range (0, len(res)):
            index_attr = res[i]["lDAPDisplayName"][0]
            if index_attr == "objectGUID":
                index_attr = "entryUUID"
            
            index_config += "index " + index_attr + " eq\n"

        # generate serverids, ldap-urls and syncrepl-blocks for mmr hosts
        mmr_on_config = ""
        mmr_replicator_acl = ""
        mmr_serverids_config = ""
        mmr_syncrepl_schema_config = "" 
        mmr_syncrepl_config_config = "" 
        mmr_syncrepl_user_config = "" 
       
    
        if self.ol_mmr_urls is not None:
            # For now, make these equal
            mmr_pass = self.ldapadminpass
        
            url_list=filter(None,self.ol_mmr_urls.split(' ')) 
            if (len(url_list) == 1):
                url_list=filter(None,self.ol_mmr_urls.split(',')) 
                     
            
                mmr_on_config = "MirrorMode On"
                mmr_replicator_acl = "  by dn=cn=replicator,cn=samba read"
                serverid=0
                for url in url_list:
                    serverid=serverid+1
                    mmr_serverids_config += read_and_sub_file(self.setup_path("mmr_serverids.conf"),
                                                          { "SERVERID" : str(serverid),
                                                            "LDAPSERVER" : url })
                    rid=serverid*10
                    rid=rid+1
                    mmr_syncrepl_schema_config += read_and_sub_file(self.setup_path("mmr_syncrepl.conf"),
                                                                {  "RID" : str(rid),
#.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:103,代码来源:provisionbackend.py


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