mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
more lint fixes
This commit is contained in:
parent
44e7bf7b0c
commit
640864d92a
@ -7,8 +7,6 @@ from __future__ import absolute_import
|
||||
|
||||
import salt.utils
|
||||
from salt.ext.six import string_types
|
||||
#from salt._compat import string_types
|
||||
|
||||
|
||||
try:
|
||||
import win32com.client
|
||||
@ -235,7 +233,7 @@ def adduser(name, username):
|
||||
if 'dc=' in username.lower():
|
||||
groupObj.Add('LDAP://' + username)
|
||||
else:
|
||||
#have to use a different ADSPath when adding/removing users to Domain Groups...
|
||||
# have to use a different ADSPath when adding/removing users to Domain Groups...
|
||||
with salt.utils.winapi.Com():
|
||||
c = wmi.WMI()
|
||||
for wmiComp in c.Win32_ComputerSystem():
|
||||
@ -303,7 +301,7 @@ def deluser(name, username):
|
||||
if 'dc=' in username.lower():
|
||||
groupObj.Remove('LDAP://' + username)
|
||||
else:
|
||||
#have to use a different ADSPath when adding/removing users to Domain Groups...
|
||||
# have to use a different ADSPath when adding/removing users to Domain Groups...
|
||||
with salt.utils.winapi.Com():
|
||||
c = wmi.WMI()
|
||||
for wmiComp in c.Win32_ComputerSystem():
|
||||
@ -385,7 +383,7 @@ def members(name, members_list):
|
||||
else:
|
||||
ret['result'] = False
|
||||
ret['comment'].append(this_return['comment'])
|
||||
#remove users not in the list
|
||||
# remove users not in the list
|
||||
for member in current_info['members']:
|
||||
if member.lower() not in [x.lower() for x in members_list]:
|
||||
this_return = deluser(name, member)
|
||||
@ -415,12 +413,10 @@ def list_groups(useldap=False):
|
||||
nt = win32com.client.Dispatch('AdsNameSpaces')
|
||||
|
||||
if useldap:
|
||||
'''
|
||||
try to recurse through the ldap server and get all user objects...
|
||||
could do 'LDAP:' and allow any domain member the ability to get all ldap users
|
||||
if anonymous binds are allowed, but for now, the code will try to connect to ldap on the local
|
||||
host
|
||||
'''
|
||||
# try to recurse through the ldap server and get all user objects...
|
||||
# could do 'LDAP:' and allow any domain member the ability to get all ldap users
|
||||
# if anonymous binds are allowed, but for now, the code will try to connect to ldap on the local
|
||||
# host
|
||||
ret = _recursecontainersforgroups('LDAP://localhost')
|
||||
else:
|
||||
results = nt.GetObject('', 'WinNT://.')
|
||||
|
@ -10,13 +10,11 @@ from __future__ import absolute_import
|
||||
|
||||
import salt.utils
|
||||
from salt.ext.six import string_types
|
||||
from salt.exceptions import CommandExecutionError
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import win32net
|
||||
import win32netcon
|
||||
import win32security
|
||||
import win32com.client
|
||||
@ -103,12 +101,9 @@ def add(name,
|
||||
if compObj is not None:
|
||||
newUser = compObj.Create('user', addUserName)
|
||||
if ldapProvider:
|
||||
'''
|
||||
ldap provider seems to require 'SetInfo' before you can set the password (opposite of WinNT provider)
|
||||
also must set the account to 'enabled' as default is disabled
|
||||
|
||||
lots of LDAP properties could be added here/to the function
|
||||
'''
|
||||
# ldap provider seems to require 'SetInfo' before you can set the password (opposite of WinNT provider)
|
||||
# also must set the account to 'enabled' as default is disabled
|
||||
# lots of LDAP properties could be added here/to the function
|
||||
newUser.sAMAccountName = addUserName.replace('cn=', '').replace('CN=', '')
|
||||
newUser.userPrincipalName = addUserName.replace('cn=', '').replace(
|
||||
'CN=', '') + '@' + name[(name.find('dc=') + 3):len(name)].replace(
|
||||
@ -696,11 +691,8 @@ def chgroups(name, groups, append=False):
|
||||
current_info['groups'].sort()
|
||||
|
||||
if current_info:
|
||||
#existing_groups = [x.lower() for x in current_info['groups']]
|
||||
#existing_groups.sort()
|
||||
|
||||
if [x.lower() for x in groups] == [x.lower() for x in current_info['groups']]:
|
||||
#nothing done
|
||||
# nothing done
|
||||
ret['result'] = None
|
||||
ret['changes'] = None
|
||||
ret['comment'].append((
|
||||
@ -720,7 +712,7 @@ def chgroups(name, groups, append=False):
|
||||
else:
|
||||
for group in current_info['groups']:
|
||||
if group.lower() not in [x.lower() for x in groups]:
|
||||
#remove it
|
||||
# remove it
|
||||
thisRet = removegroup(name, group)
|
||||
if thisRet['result']:
|
||||
ret['changes']['Groups Removed'].append(group)
|
||||
@ -730,7 +722,7 @@ def chgroups(name, groups, append=False):
|
||||
return ret
|
||||
for group in groups:
|
||||
if group.lower() not in [x.lower() for x in current_info['groups']]:
|
||||
#add it
|
||||
# add it
|
||||
thisRet = addgroup(name, group)
|
||||
if thisRet['result']:
|
||||
ret['changes']['Groups Added'].append(group)
|
||||
@ -773,8 +765,6 @@ def info(name):
|
||||
'gid': ''}
|
||||
try:
|
||||
if 'dc=' in name.lower():
|
||||
#ldapServer = name.split('dc=', 1)[1].replace('dc=', '.').replace(',', '')
|
||||
#userObj = nt.GetObject('', 'LDAP://' + ldapServer + '/' + name)
|
||||
userObj = nt.GetObject('', 'LDAP://' + name)
|
||||
ret['active'] = (not bool(userObj.userAccountControl & win32netcon.UF_ACCOUNTDISABLE))
|
||||
ret['logonscript'] = userObj.scriptPath
|
||||
@ -881,12 +871,10 @@ def list_users(useldap=False):
|
||||
nt = win32com.client.Dispatch('AdsNameSpaces')
|
||||
|
||||
if useldap:
|
||||
'''
|
||||
try to recurse through the ldap server and get all user objects...
|
||||
could do 'LDAP:' and allow any domain member the ability to get all ldap users
|
||||
if anonymous binds are allowed, but for now, the code will try to connect to ldap on the local
|
||||
host
|
||||
'''
|
||||
# try to recurse through the ldap server and get all user objects...
|
||||
# could do 'LDAP:' and allow any domain member the ability to get all ldap users
|
||||
# if anonymous binds are allowed, but for now, the code will try to connect to ldap on the local
|
||||
# host
|
||||
ret = _recursecontainersforusers('LDAP://localhost')
|
||||
else:
|
||||
results = nt.GetObject('', 'WinNT://.')
|
||||
|
Loading…
Reference in New Issue
Block a user