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


Python Net.set_password方法代码示例

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


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

示例1: run

# 需要导入模块: from samba.net import Net [as 别名]
# 或者: from samba.net.Net import set_password [as 别名]
 def run(self, name, password=None, credopts=None, sambaopts=None, versionopts=None):
     lp = sambaopts.get_loadparm()
     creds = credopts.get_credentials(lp )
     net = Net(creds, lp, server=credopts.ipaddress)
     net.create_user(name)
     if password is not None:
         net.set_password(name, creds.get_domain(), password, creds)
开发者ID:Arkhont,项目名称:samba,代码行数:9,代码来源:user.py

示例2: test_net_set_password

# 需要导入模块: from samba.net import Net [as 别名]
# 或者: from samba.net.Net import set_password [as 别名]
    def test_net_set_password(self):

        dn = "CN=" + USER_NAME + ",CN=Users," + self.base_dn
        self.discardSetupMessages(dn)

        creds = self.insta_creds(template=self.get_credentials())

        lp = self.get_loadparm()
        net = Net(creds, lp, server=self.server)
        password = "newPassword!!42"
        domain = lp.get("workgroup")

        net.set_password(newpassword=password.encode('utf-8'),
                         account_name=USER_NAME,
                         domain_name=domain)
        messages = self.waitForMessages(1, net, dn=dn)
        print("Received %d messages" % len(messages))
        self.assertEquals(1,
                          len(messages),
                          "Did not receive the expected number of messages")
        audit = messages[0]["dsdbChange"]
        self.assertEquals("Modify", audit["operation"])
        self.assertFalse(audit["performedAsSystem"])
        self.assertEquals(dn, audit["dn"])
        self.assertRegexpMatches(audit["remoteAddress"],
                                 self.remoteAddress)
        session_id = self.get_session()
        self.assertEquals(session_id, audit["sessionId"])
        # We skip the check for self.get_service_description() as this
        # is subject to a race between smbd and the s4 rpc_server code
        # as to which will set the description as it is DCE/RPC over SMB

        self.assertTrue(self.is_guid(audit["transactionId"]))

        attributes = audit["attributes"]
        self.assertEquals(1, len(attributes))
        actions = attributes["clearTextPassword"]["actions"]
        self.assertEquals(1, len(actions))
        self.assertTrue(actions[0]["redacted"])
        self.assertEquals("replace", actions[0]["action"])
开发者ID:Alexander--,项目名称:samba,代码行数:42,代码来源:audit_log_dsdb.py


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