1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Now the machine removal on windows takes care of child nodes.. (We have

noticed that Hyperv server 2016 creates a "node" behind machines on
domain)
This commit is contained in:
Adolfo Gómez García 2018-05-10 12:32:10 +02:00
parent 962d28b484
commit 15e4c949d3
2 changed files with 13 additions and 4 deletions

View File

@ -169,3 +169,15 @@ def getFirst(con, base, objectClass, field, value, attributes=None, sizeLimit=50
return obj
# Recursive delete
def recursive_delete(con, base_dn):
search = con.search_s(base_dn, ldap.SCOPE_ONELEVEL)
for dn, _ in search:
# recursive_delete(conn, dn)
# RIGHT NOW IS NOT RECURSIVE, JUST 1 LEVEL BELOW!!!
con.delete_s(dn)
con.delete_s(base_dn)

View File

@ -209,10 +209,7 @@ class WinDomainOsManager(WindowsOsManager):
res = self.__getMachine(l, service.friendly_name)
if res is None:
raise Exception('Machine {} not found on AD (permissions?)'.format(service.friendly_name))
# #
# Direct LDAP operation "modify", maybe this need to be added to ldaputil? :)
# #
l.delete_s(res) # Remove by DN, SYNC
ldaputil.recursive_delete(l, res)
except IndexError:
logger.error('Error deleting {} from BASE {}'.format(service.friendly_name, self._ou))
except Exception: