本文整理汇总了Python中mmc.plugins.samba.smb_conf.SambaConf.save方法的典型用法代码示例。如果您正苦于以下问题:Python SambaConf.save方法的具体用法?Python SambaConf.save怎么用?Python SambaConf.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmc.plugins.samba.smb_conf.SambaConf
的用法示例。
在下文中一共展示了SambaConf.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modShare
# 需要导入模块: from mmc.plugins.samba.smb_conf import SambaConf [as 别名]
# 或者: from mmc.plugins.samba.smb_conf.SambaConf import save [as 别名]
def modShare(
name, path, comment, usergroups, users, permAll, admingroups, browseable=True, av=0, customparameters=None
):
smbObj = SambaConf(SambaConfig("samba").samba_conf_file)
smbObj.addShare(
name, path, comment, usergroups, users, permAll, admingroups, browseable, av, customparameters, True
)
smbObj.save()
示例2: activate
# 需要导入模块: from mmc.plugins.samba.smb_conf import SambaConf [as 别名]
# 或者: from mmc.plugins.samba.smb_conf.SambaConf import save [as 别名]
#.........这里部分代码省略.........
samba = SambaLDAP()
# Create SAMBA computers account OU if it doesn't exist
head, path = samba.baseComputersDN.split(",", 1)
ouName = head.split("=")[1]
samba.addOu(ouName, path)
# Check that a sambaDomainName entry is in LDAP directory
domainInfos = samba.getDomain()
# Set domain policy
samba.setDomainPolicy()
if not domainInfos:
logger.error(
"Can't find sambaDomainName entry in LDAP for domain %s. Please check your SAMBA LDAP configuration."
% smbconf.getContent("global", "workgroup")
)
return False
smbconfbasesuffix = smbconf.getContent("global", "ldap suffix")
if not smbconfbasesuffix:
logger.error("SAMBA 'ldap suffix' option is not setted.")
return False
if ldap.explode_dn(samba.baseDN) != ldap.explode_dn(smbconfbasesuffix):
logger.error("SAMBA 'ldap suffix' option is not equal to MMC 'baseDN' option.")
return False
# Check that SAMBA and MMC given OU are in sync
for option in [
("ldap user suffix", "baseUsersDN", samba.baseUsersDN),
("ldap group suffix", "baseGroupsDN", samba.baseGroupsDN),
("ldap machine suffix", "baseComputersDN", samba.baseComputersDN),
]:
smbconfsuffix = smbconf.getContent("global", option[0])
if not smbconfsuffix:
logger.error("SAMBA '" + option[0] + "' option is not setted")
return False
# Do a case insensitive comparison of the corresponding MMC / SAMBA options
if ldap.explode_rdn(smbconfsuffix)[0].lower() != ldap.explode_rdn(option[2])[0].lower():
logger.error("SAMBA option '" + option[0] + "' is not equal to MMC '" + option[1] + "' option.")
return False
# Check that "ldap delete dn" SAMBA option is set to "No"
smbconfdeletedn = smbconf.isValueTrue(smbconf.getContent("global", "ldap delete dn"))
if smbconfdeletedn == 1:
logger.error("SAMBA option 'ldap delete dn' must be disabled.")
return False
# Check that Domain Computers group exists
# We need it to put a machine account in the right group when joigning it to the domain
if not samba.getDomainComputersGroup():
logger.error(
"Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Computers' group. Please check your SAMBA LDAP configuration."
)
return False
# Check that Domain Admins group exists
if not samba.getDomainAdminsGroup():
logger.error(
"Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Admins' group. Please check your SAMBA LDAP configuration."
)
return False
# Check that Domain Guests group exists
if not samba.getDomainGuestsGroup():
logger.error(
"Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Guests' group. Please check your SAMBA LDAP configuration."
)
return False
# Check that Domain Users group exists
if not samba.getDomainUsersGroup():
logger.error(
"Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Users' group. Please check your SAMBA LDAP configuration."
)
return False
# Check that add machine script option is set, and that the given script exist
addMachineScript = smbconf.getContent("global", "add machine script")
if not addMachineScript:
logger.error("SAMBA 'add machine script' option is not set.")
return False
else:
script = addMachineScript.split(" ")[0]
if not os.path.exists(script):
logger.error("SAMBA 'add machine script' option is set to a non existing file: " + script)
return False
# Issue a warning if NSCD is running
if (
os.path.exists("/var/run/nscd.pid")
or os.path.exists("/var/run/.nscd_socket")
or os.path.exists("/var/run/nscd")
):
logger.warning("Looks like NSCD is installed on your system. You should not run NSCD on a SAMBA server.")
# Check that os level is set to 255
oslevel = smbconf.getContent("global", "os level")
if int(oslevel) < 255:
logger.debug("Set SAMBA os level to 255.")
smbconf.setContent("global", "os level", "255")
smbconf.save()
reloadSamba()
try:
from mmc.plugins.dashboard.manager import DashboardManager
from mmc.plugins.samba.panel import SambaPanel
DM = DashboardManager()
DM.register_panel(SambaPanel("samba"))
except ImportError:
pass
return True
示例3: delShare
# 需要导入模块: from mmc.plugins.samba.smb_conf import SambaConf [as 别名]
# 或者: from mmc.plugins.samba.smb_conf.SambaConf import save [as 别名]
def delShare(name, file):
smbObj = SambaConf(SambaConfig("samba").samba_conf_file)
smbObj.delShare(name, file)
smbObj.save()
return 0
示例4: addShare
# 需要导入模块: from mmc.plugins.samba.smb_conf import SambaConf [as 别名]
# 或者: from mmc.plugins.samba.smb_conf.SambaConf import save [as 别名]
def addShare(name, path, comment, perms, admingroups, recursive=True, browseable=True, av=0, customparameters=None):
smbObj = SambaConf(SambaConfig("samba").samba_conf_file)
smbObj.addShare(name, path, comment, perms, admingroups, recursive, browseable, av, customparameters)
smbObj.save()