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


Python audit.AuditFactory类代码示例

本文整理汇总了Python中mmc.core.audit.AuditFactory的典型用法代码示例。如果您正苦于以下问题:Python AuditFactory类的具体用法?Python AuditFactory怎么用?Python AuditFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setSubnetAuthoritative

    def setSubnetAuthoritative(self, subnet, flag = True):
        """
        Set the subnet as authoritative or 'not authoritative'

        @param subnet: the network address of the subnet
        @type subnet: str

        @param flag: whether the subnet is authoritative or not
        @type flag: bool
        """
        r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_SUBNET_AUTH, [(subnet, AT.SUBNET)], flag)
        subnets = self.getSubnet(subnet)
        if subnets:
            subnetDN = subnets[0][0]
            options = self.getObjectStatements(subnetDN)
            newoptions = []
            for option in options:
                if not option in ["authoritative", "not authoritative"]:
                    newoptions.append(option)
            if flag:
                newoptions.append("authoritative")
            else:
                newoptions.append("not authoritative")
            self.l.modify_s(subnetDN, [(ldap.MOD_REPLACE, "dhcpStatements", newoptions)])
        r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:25,代码来源:dhcp.py

示例2: setSubnetNetmask

 def setSubnetNetmask(self, subnet, netmask):
     r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_SUBNET_NTMSK, [(subnet, AT.SUBNET)], netmask)
     subnets = self.getSubnet(subnet)
     if subnets:
         subnetDN = subnets[0][0]
         self.l.modify_s(subnetDN, [(ldap.MOD_REPLACE, "dhcpNetMask", netmask)])
     r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:7,代码来源:dhcp.py

示例3: disableUser

 def disableUser(self, uid):
     """
     Disable the SAMBA user
     """
     userdn = self.searchUserDN(uid)
     r = AF().log(PLUGIN_NAME, AA.SAMBA_DISABLE_USER, [(userdn, AT.USER)])
     s = self.l.search_s(userdn, ldap.SCOPE_BASE)
     c, old = s[0]
     new = old.copy()
     flags = new["sambaAcctFlags"][0]
     # flags should be something like "[U          ]"
     flags = flags.strip("[]")
     flags = flags.strip()
     if flags.startswith("D"):
         # Huh ? User has been already disabled
         # Do nothing
         pass
     else:
         flags = "D" + flags
         flags = "[" + flags.ljust(11) + "]"
         new["sambaAcctFlags"] = [flags]
         modlist = ldap.modlist.modifyModlist(old, new)
         self.l.modify_s(userdn, modlist)
     r.commit()
     return 0
开发者ID:sebastiendu,项目名称:mmc,代码行数:25,代码来源:smb_ldap.py

示例4: delBlacklist

 def delBlacklist(self, elt):
     """Remove an element from the blacklist"""
     r = AF().log(PLUGIN_NAME, AA.PROXY_DEL_BLACKLIST, [(elt, AT.BLACKLIST)])
     if elt in self.contentArr:
         self.contentArr.remove(elt)
     self.saveBlacklist()
     r.commit()
开发者ID:AnatomicJC,项目名称:mmc,代码行数:7,代码来源:__init__.py

示例5: setHostStatement

 def setHostStatement(self, subnet, host, option, value):
     r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_HOST_STMT, [(subnet, AT.SUBNET),(host, AT.HOST), (option,"OPTION")], value)
     hosts = self.getHost(subnet, host)
     if hosts:
         hostDN = hosts[0][0]
         self.setObjectStatement(hostDN, option, value)
     r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:7,代码来源:dhcp.py

示例6: setHostHWAddress

 def setHostHWAddress(self, subnet, host, address):
     r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_HOST_HWADD, [(subnet, AT.SUBNET),(host, AT.HOST)], address)
     hosts = self.getHost(subnet, host)
     if hosts:
         hostDN = hosts[0][0]
         self.l.modify_s(hostDN, [(ldap.MOD_REPLACE, "dhcpHWAddress", ["ethernet " + address])])
     r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:7,代码来源:dhcp.py

示例7: setPoolRange

 def setPoolRange(self, pool, start, end):
     r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_POOLRANGE, [(pool, AT.POOL)])
     pools = self.getPool(pool)
     if pools:
         poolDN = pools[0][0]
         self.l.modify_s(poolDN, [(ldap.MOD_REPLACE, "dhcpRange", start + " " + end)])
     r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:7,代码来源:dhcp.py

示例8: delZone

    def delZone(self, zone):
        """
        Delete a DNS zone with all its reverse zones

        @param name: the zone name to delete
        """
        r = AF().log(PLUGIN_NAME, AA.NETWORK_DEL_DNS_ZONE, [(zone, AT.ZONE)])
        if self.pdns:
            zoneDN = "dc=" + zone + "," + self.configDns.dnsDN
            self.delRecursiveEntry(zoneDN)
            reverseDN = self.getReverseZone(zone)
            if reverseDN[0]:
                self.delRecursiveEntry("dc=" + reverseDN[0] + "," + self.configDns.dnsDN)
        else:
            zoneDN = "ou=" + zone + "," + self.configDns.dnsDN
            self.delRecursiveEntry(zoneDN)
            os.unlink(os.path.join(self.configDns.bindLdapDir, zone))
            newcontent = []
            f = open(self.configDns.bindLdap, "r")
            for line in f:
                if not "/" + zone + '";' in line:
                    newcontent.append(line)
            f.close()
            f = open(self.configDns.bindLdap, "w+")
            for line in newcontent:
                f.write(line)
            f.close()
        r.commit()
开发者ID:allgi,项目名称:mmc,代码行数:28,代码来源:dns.py

示例9: setSubnetStatement

 def setSubnetStatement(self, subnet, option, value = None):
     r = AF().log(PLUGIN_NAME, AA.NETWORK_SET_SUBNET_STMT, [(subnet, AT.SUBNET), (option, "OPTION")], value)
     subnets = self.getSubnet(subnet)
     if subnets:
         subnetDN = subnets[0][0]
         self.setObjectStatement(subnetDN, option, value)
     r.commit()
开发者ID:neoclust,项目名称:pulse,代码行数:7,代码来源:dhcp.py

示例10: setPPolicyAttribute

    def setPPolicyAttribute(self, nameattribute, value):
        """
        Set the value of the given LDAP attribute.
        Del the attribute if value is None

        @param nameattribute: LDAP attribute name
        @type nameattribute: str

        @param value: LDAP attribute value
        @type value: str
        """
        if value != None:
            r = AF().log(
                PLUGIN_NAME, AA.PPOLICY_MOD_USER_ATTR, [(self.dn, AT.USER), (nameattribute, AT.ATTRIBUTE)], value
            )
            if type(value) == bool:
                value = str(value).upper()
            elif type(value) == int:
                value = str(value)
            mode = ldap.MOD_REPLACE
            logging.getLogger().debug("Setting %s to %s" % (nameattribute, value))
        else:
            r = AF().log(
                PLUGIN_NAME, AA.PPOLICY_DEL_USER_ATTR, [(self.dn, AT.USER), (nameattribute, AT.ATTRIBUTE)], value
            )
            mode = ldap.MOD_DELETE
            logging.getLogger().debug("Removing %s" % nameattribute)
        try:
            self.l.modify_s(self.dn, [(mode, nameattribute, value)])
        except ldap.UNDEFINED_TYPE:
            logging.getLogger().error("Attribute %s isn't defined on LDAP" % nameattribute)
        except ldap.INVALID_SYNTAX:
            logging.getLogger().error("Invalid Syntax from the attribute value of %s on ldap" % nameattribute)
        r.commit()
开发者ID:vmasilva,项目名称:mmc,代码行数:34,代码来源:__init__.py

示例11: setPasswdExpiration

 def setPasswdExpiration(self, uid, can_expire=False):
     """
     Set password expiration flag on SAMBA user
     """
     userdn = self.searchUserDN(uid)
     action = AA.SAMBA_UNEXPIRE_USER_PASSWD
     if can_expire:
         action = AA.SAMBA_EXPIRE_USER_PASSWD
     s = self.l.search_s(userdn, ldap.SCOPE_BASE)
     c, old = s[0]
     new = old.copy()
     changed = False
     flags = new["sambaAcctFlags"][0]
     # flags should be something like "[U          ]"
     if can_expire and 'X' in flags:
         flags = flags.strip("[]")
         flags = flags.strip().replace('X', '')
         flags = "[" + flags.ljust(11) + "]"
         changed = True
     elif not can_expire and not 'X' in flags:
         flags = flags.strip("[]").strip()
         flags = flags + "X"
         flags = "[" + flags.ljust(11) + "]"
         changed = True
     # If the flag was changed
     if changed:
         r = AF().log(PLUGIN_NAME, action, [(userdn, AT.USER)])
         new["sambaAcctFlags"] = [flags]
         modlist = ldap.modlist.modifyModlist(old, new)
         self.l.modify_s(userdn, modlist)
         r.commit()
     return True
开发者ID:sebastiendu,项目名称:mmc,代码行数:32,代码来源:smb_ldap.py

示例12: updatePPolicy

    def updatePPolicy(self, ppolicyName):
        """
        Update the pwdPolicySubentry attribute of the current user
        """
        if self.hasPPolicy():
            if not ppolicyName:
                return self.removePPolicy()
            else:
                # get the ppolicy dn
                ppolicyDN = PPolicy().getPPolicy(ppolicyName)[0]
                r = AF().log(PLUGIN_NAME, AA.PPOLICY_MOD_USER_PPOLICY, [(self.dn, AT.USER)])
                try:
                    self.l.modify_s(self.dn, [(ldap.MOD_REPLACE, "pwdPolicySubentry", ppolicyDN)])
                except ldap.UNDEFINED_TYPE:
                    logging.getLogger().error("Attribute %s isn't defined on ldap" % "pwdPolicySubentry")
                except ldap.INVALID_SYNTAX:
                    logging.getLogger().error(
                        "Invalid Syntax from the attribute value of %s on ldap" % "pwdPolicySubentry"
                    )
                r.commit()
                return True
        else:
            return self.addPPolicy(ppolicyName)

        return False
开发者ID:vmasilva,项目名称:mmc,代码行数:25,代码来源:__init__.py

示例13: backupShare

def backupShare(share, media, login):
    """
    Launch as a background process the backup of a share
    """
    r = AF().log(PLUGIN_NAME, AA.SAMBA_BACKUP_SHARE, [(share, AT.SHARE), (login, AT.USER)], media)
    config = BasePluginConfig("base")
    cmd = os.path.join(config.backuptools, "backup.sh")
    if share == "homes":
        #  FIXME: Maybe we should have a configuration directive to tell that
        #  all users home are stored into /home
        savedir = "/home/"
    else:
        smbObj = SambaConf(SambaConfig("samba").samba_conf_file)
        savedir = smbObj.getContent(share, "path")
    # Run backup process in background
    shlaunchBackground(
        cmd
        + " "
        + share
        + " "
        + savedir
        + " "
        + config.backupdir
        + " "
        + login
        + " "
        + media
        + " "
        + config.backuptools,
        "backup share " + share,
        progressBackup,
    )
    r.commit()
    return os.path.join(config.backupdir, "%s-%s-%s" % (login, share, strftime("%Y%m%d")))
开发者ID:pavelpromin,项目名称:mmc,代码行数:34,代码来源:__init__.py

示例14: setZarafaGroup

    def setZarafaGroup(self, group, value):
        """
        @param group: group name
        @type group: str

        @param value: to set or unset the zarafa-group class
        @type value: boolean

        Set/unset zarafa-group object class to a user group
        """
        if value:
            event = AA.MAIL_ADD_ZARAFA_CLASS
        else:
            event = AA.MAIL_DEL_ZARAFA_CLASS
        r = AF().log(PLUGIN_NAME, event, [(group, AT.MAIL_GROUP)], group)
        group = group.encode("utf-8")
        cn = 'cn=' + group + ', ' + self.baseGroupsDN
        attrs = []
        attrib = self.l.search_s(cn, ldap.SCOPE_BASE)
        c, attrs = attrib[0]
        newattrs = copy.deepcopy(attrs)
        if value and not 'zarafa-group' in newattrs['objectClass']:
            newattrs["objectClass"].append('zarafa-group')
        elif not value and 'zarafa-group' in newattrs['objectClass']:
            newattrs["objectClass"].remove('zarafa-group')
        mlist = ldap.modlist.modifyModlist(attrs, newattrs)
        if mlist:
            self.l.modify_s(cn, mlist)
        r.commit()
开发者ID:AnatomicJC,项目名称:mmc,代码行数:29,代码来源:__init__.py

示例15: changeUserPasswd

    def changeUserPasswd(self, uid, passwd, oldpasswd = None, bind = False):
        """
        change SAMBA user password

        @param uid: user name
        @type  uid: str

        @param passwd: non encrypted password
        @type  passwd: str
        """

        # Don't update the password if we are using smbk5passwd
        conf = SambaConf()
        if conf.isValueTrue(conf.getContent("global", "ldap passwd sync")) in (0, 1):
            userdn = self.searchUserDN(uid)
            r = AF().log(PLUGIN_NAME, AA.SAMBA_CHANGE_USER_PASS, [(userdn,AT.USER)])
            # If the passwd has been encoded in the XML-RPC stream, decode it
            if isinstance(passwd, xmlrpclib.Binary):
                passwd = str(passwd)
            s = self.l.search_s(userdn, ldap.SCOPE_BASE)
            c, old = s[0]
            new = old.copy()
            new['sambaLMPassword'] = [smbpasswd.lmhash(passwd)]
            new['sambaNTPassword'] = [smbpasswd.nthash(passwd)]
            new['sambaPwdLastSet'] = [str(int(time()))]
            # Update LDAP
            modlist = ldap.modlist.modifyModlist(old, new)
            self.l.modify_s(userdn, modlist)
            self.runHook("samba.changeuserpasswd", uid, passwd)
            r.commit()

        return 0
开发者ID:sebastiendu,项目名称:mmc,代码行数:32,代码来源:smb_ldap.py


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