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


Python Message.dn方法代码示例

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


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

示例1: test_urgent_attributes

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_urgent_attributes(self):
        '''Test if the urgent replication is activated
            when handling urgent attributes of an object'''

        self.ldb.add({
            "dn": "cn=user UrgAttr test,cn=users," + self.base_dn,
            "objectclass":"user",
            "samaccountname":"user UrgAttr test",
            "userAccountControl":str(dsdb.UF_NORMAL_ACCOUNT),
            "lockoutTime":"0",
            "pwdLastSet":"0",
            "description":"urgent attributes test description"})

        # urgent replication should NOT be enabled when creating
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying userAccountControl 
        m = Message()
        m.dn = Dn(ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        m["userAccountControl"] = MessageElement(str(dsdb.UF_NORMAL_ACCOUNT+dsdb.UF_SMARTCARD_REQUIRED), FLAG_MOD_REPLACE,
          "userAccountControl")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying lockoutTime
        m = Message()
        m.dn = Dn(ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        m["lockoutTime"] = MessageElement("1", FLAG_MOD_REPLACE,
          "lockoutTime")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying pwdLastSet
        m = Message()
        m.dn = Dn(ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        m["pwdLastSet"] = MessageElement("1", FLAG_MOD_REPLACE,
          "pwdLastSet")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when modifying a not-urgent
        # attribute
        m = Message()
        m.dn = Dn(ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        m["description"] = MessageElement("updated urgent attributes test description",
                                          FLAG_MOD_REPLACE, "description")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when deleting
        self.delete_force(self.ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:60,代码来源:urgent_replication.py

示例2: test_secret_object

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_secret_object(self):
        """Test if the urgent replication is activated when handling a secret object."""

        self.ldb.add({
            "dn": "cn=test secret,cn=System," + self.base_dn,
            "objectClass":"secret",
            "cn":"test secret",
            "name":"test secret",
            "currentValue":"xxxxxxx"})

        # urgent replication should be enabled when creating
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying
        m = Message()
        m.dn = Dn(self.ldb, "cn=test secret,cn=System," + self.base_dn)
        m["currentValue"] = MessageElement("yyyyyyyy", FLAG_MOD_REPLACE,
          "currentValue")
        self.ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when deleting
        self.delete_force(self.ldb, "cn=test secret,cn=System," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:bhanug,项目名称:samba,代码行数:29,代码来源:urgent_replication.py

示例3: test_u1_member_of_g4

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_u1_member_of_g4(self):
        i = 0
        import time
        print "KEYS: total add modify delete"
        
        while True:
            group = i % self.n_groups + 1
            
            start = time.time()
            self.ldb.add({
                "dn": "cn=u%d,%s" % (group, self.ou_users), "objectclass": "user"})
            end_add = time.time()

            start_mod = time.time()
            
            m = Message()
            m.dn = Dn(self.ldb, "CN=g%d,%s" % (group, self.ou_groups))
            m["member"] = MessageElement("cn=u%d,%s" % (group, self.ou_users),
                                         FLAG_MOD_ADD, "member")
            self.ldb.modify(m)
            end_mod = time.time()

            delete_force(self.ldb, "cn=u%d,%s" % (group, self.ou_users))
            end = time.time()
            print end - start, end_add - start, end_mod - start_mod, end - end_mod
            i += 1
开发者ID:GSam,项目名称:samba-cloud-autobuild,代码行数:28,代码来源:test_latency-4.1.py

示例4: test_attributeSchema_object

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_attributeSchema_object(self):
        """Test if the urgent replication is activated when handling an attributeSchema object"""

        self.ldb.add_ldif(
            """dn: CN=test attributeSchema,cn=Schema,CN=Configuration,%s""" % self.base_dn + """
objectClass: attributeSchema
cn: test attributeSchema
instanceType: 4
isSingleValued: FALSE
showInAdvancedViewOnly: FALSE
attributeID: 1.3.6.1.4.1.7165.4.6.1.4.""" + str(random.randint(1,100000)) + """
attributeSyntax: 2.5.5.12
adminDisplayName: test attributeSchema
adminDescription: test attributeSchema
oMSyntax: 64
systemOnly: FALSE
searchFlags: 8
lDAPDisplayName: testAttributeSchema
name: test attributeSchema""")

        # urgent replication should be enabled when creating
        res = self.ldb.load_partition_usn("cn=Schema,cn=Configuration," + self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying
        m = Message()
        m.dn = Dn(self.ldb, "CN=test attributeSchema,CN=Schema,CN=Configuration," + self.base_dn)
        m["lDAPDisplayName"] = MessageElement("updatedTestAttributeSchema", FLAG_MOD_REPLACE,
          "lDAPDisplayName")
        self.ldb.modify(m)
        res = self.ldb.load_partition_usn("cn=Schema,cn=Configuration," + self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:bhanug,项目名称:samba,代码行数:34,代码来源:urgent_replication.py

示例5: _unlink_user_and_group

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
 def _unlink_user_and_group(self, u, g):
     user = "cn=u%d,%s" % (u, self.ou_users)
     group = "CN=g%d,%s" % (g, self.ou_groups)
     m = Message()
     m.dn = Dn(self.ldb, group)
     m["member"] = MessageElement(user, FLAG_MOD_DELETE, "member")
     self.ldb.modify(m)
开发者ID:DavidMulder,项目名称:samba,代码行数:9,代码来源:ad_dc_performance.py

示例6: test_rIDManager_object

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_rIDManager_object(self):
        """Test if the urgent replication is activated when handling a rIDManager object."""
        self.ldb.add_ldif(
            """dn: CN=RID Manager test,CN=System,%s""" % self.base_dn + """
objectClass: rIDManager
cn: RID Manager test
instanceType: 4
showInAdvancedViewOnly: TRUE
name: RID Manager test
systemFlags: -1946157056
isCriticalSystemObject: TRUE
rIDAvailablePool: 133001-1073741823""", ["relax:0"])

        # urgent replication should be enabled when creating
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should be enabled when modifying
        m = Message()
        m.dn = Dn(self.ldb, "CN=RID Manager test,CN=System," + self.base_dn)
        m["systemFlags"] = MessageElement("0", FLAG_MOD_REPLACE,
          "systemFlags")
        self.ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when deleting 
        self.delete_force(self.ldb, "CN=RID Manager test,CN=System," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:bhanug,项目名称:samba,代码行数:32,代码来源:urgent_replication.py

示例7: _test_link_many_users_batch

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def _test_link_many_users_batch(self, n=(LINK_BATCH_SIZE * 10)):
        # this links unevenly, putting more users in the first group
        # and fewer in the last.
        ng = self.state.n_groups
        nu = self.state.next_user_id
        messages = []
        for g in range(ng):
            m = Message()
            m.dn = Dn(self.ldb, "CN=g%d,%s" % (g, self.ou_groups))
            messages.append(m)

        while n:
            u = random.randrange(nu)
            g = random.randrange(random.randrange(ng) + 1)
            link = (u, g)
            if link in self.state.active_links:
                continue
            m = messages[g]
            m["member%s" % u] = MessageElement("cn=u%d,%s" %
                                               (u, self.ou_users),
                                               FLAG_MOD_ADD, "member")
            self.state.active_links.add(link)
            n -= 1

        for m in messages:
            try:
                self.ldb.modify(m)
            except LdbError as e:
                print(e)
                print(m)
开发者ID:DavidMulder,项目名称:samba,代码行数:32,代码来源:ad_dc_medley_performance.py

示例8: test_crossRef_object

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_crossRef_object(self):
        """Test if the urgent replication is activated when handling a crossRef object."""
        self.ldb.add({
                      "dn": "CN=test crossRef,CN=Partitions,CN=Configuration,"+ self.base_dn,
                      "objectClass": "crossRef",
                      "cn": "test crossRef",
                      "dnsRoot": self.get_loadparm().get("realm").lower(),
                      "instanceType": "4",
                      "nCName": self.base_dn,
                      "showInAdvancedViewOnly": "TRUE",
                      "name": "test crossRef",
                      "systemFlags": "1"}, ["relax:0"])

        # urgent replication should be enabled when creating
        res = self.ldb.load_partition_usn("cn=Configuration," + self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when modifying
        m = Message()
        m.dn = Dn(self.ldb, "cn=test crossRef,CN=Partitions,CN=Configuration," + self.base_dn)
        m["systemFlags"] = MessageElement("0", FLAG_MOD_REPLACE,
          "systemFlags")
        self.ldb.modify(m)
        res = self.ldb.load_partition_usn("cn=Configuration," + self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])


        # urgent replication should be enabled when deleting
        self.delete_force(self.ldb, "cn=test crossRef,CN=Partitions,CN=Configuration," + self.base_dn)
        res = self.ldb.load_partition_usn("cn=Configuration," + self.base_dn)
        self.assertEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:bhanug,项目名称:samba,代码行数:33,代码来源:urgent_replication.py

示例9: test_nonurgent_object

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_nonurgent_object(self):
        """Test if the urgent replication is not activated when handling a non urgent object."""
        self.ldb.add({
            "dn": "cn=nonurgenttest,cn=users," + self.base_dn,
            "objectclass":"user",
            "samaccountname":"nonurgenttest",
            "description":"nonurgenttest description"})

        # urgent replication should not be enabled when creating
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should not be enabled when modifying
        m = Message()
        m.dn = Dn(self.ldb, "cn=nonurgenttest,cn=users," + self.base_dn)
        m["description"] = MessageElement("new description", FLAG_MOD_REPLACE,
          "description")
        self.ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should not be enabled when deleting
        self.delete_force(self.ldb, "cn=nonurgenttest,cn=users," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])
开发者ID:bhanug,项目名称:samba,代码行数:27,代码来源:urgent_replication.py

示例10: test_unicodePwd_clear_set

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_unicodePwd_clear_set(self):
        """Performs a password cleartext set operation on 'unicodePwd'"""

        m = Message()
        m.dn = Dn(self.ldb, "cn=testuser,cn=users," + self.base_dn)
        m["unicodePwd"] = MessageElement("\"thatsAcomplPASS2\"".encode('utf-16-le'),
          FLAG_MOD_REPLACE, "unicodePwd")
        self.ldb.modify(m)
开发者ID:DavidMulder,项目名称:samba,代码行数:10,代码来源:passwords.py

示例11: enable_recycle_bin

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
 def enable_recycle_bin(self):
     msg = Message()
     msg.dn = Dn(self.samdb, "")
     msg["enableOptionalFeature"] = MessageElement(
         "CN=Partitions," + self.configuration_dn + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
         FLAG_MOD_ADD, "enableOptionalFeature")
     try:
         self.samdb.modify(msg)
     except LdbError, (num, _):
         self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS)
开发者ID:runt18,项目名称:samba,代码行数:12,代码来源:tombstone_reanimation.py

示例12: test_userPassword_clear_set

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def test_userPassword_clear_set(self):
        """Performs a password cleartext set operation on 'userPassword'"""
        # Notice: This works only against Windows if "dSHeuristics" has been set
        # properly

        m = Message()
        m.dn = Dn(self.ldb, "cn=testuser,cn=users," + self.base_dn)
        m["userPassword"] = MessageElement("thatsAcomplPASS2", FLAG_MOD_REPLACE,
          "userPassword")
        self.ldb.modify(m)
开发者ID:DavidMulder,项目名称:samba,代码行数:12,代码来源:passwords.py

示例13: modify_sd_on_dn

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def modify_sd_on_dn(self, object_dn, sd, controls=None):
        """Modify security descriptor using either SDDL string
            or security.descriptor object
        """
        m = Message()
        if isinstance(object_dn, Dn):
            m.dn = object_dn
        else:
            m.dn = Dn(self.ldb, object_dn)

        assert(isinstance(sd, str) or isinstance(sd, security.descriptor))
        if isinstance(sd, str):
            tmp_desc = security.descriptor.from_sddl(sd, self.domain_sid)
        elif isinstance(sd, security.descriptor):
            tmp_desc = sd

        m["nTSecurityDescriptor"] = MessageElement(ndr_pack(tmp_desc),
                                                       FLAG_MOD_REPLACE,
                                                       "nTSecurityDescriptor")
        self.ldb.modify(m, controls)
开发者ID:Alexander--,项目名称:samba,代码行数:22,代码来源:sd_utils.py

示例14: _link_user_and_group

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def _link_user_and_group(self, u, g):
        link = (u, g)
        if link in self.state.active_links:
            return False

        m = Message()
        m.dn = Dn(self.ldb, "CN=g%d,%s" % (g, self.ou_groups))
        m["member"] = MessageElement("cn=u%d,%s" % (u, self.ou_users),
                                     FLAG_MOD_ADD, "member")
        self.ldb.modify(m)
        self.state.active_links.add(link)
        return True
开发者ID:DavidMulder,项目名称:samba,代码行数:14,代码来源:ad_dc_medley_performance.py

示例15: _unlink_user_and_group

# 需要导入模块: from ldb import Message [as 别名]
# 或者: from ldb.Message import dn [as 别名]
    def _unlink_user_and_group(self, u, g):
        link = (u, g)
        if link not in self.state.active_links:
            return False

        user = "cn=u%d,%s" % (u, self.ou_users)
        group = "CN=g%d,%s" % (g, self.ou_groups)
        m = Message()
        m.dn = Dn(self.ldb, group)
        m["member"] = MessageElement(user, FLAG_MOD_DELETE, "member")
        self.ldb.modify(m)
        self.state.active_links.remove(link)
        return True
开发者ID:DavidMulder,项目名称:samba,代码行数:15,代码来源:ad_dc_medley_performance.py


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