1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-27 07:42:04 +03:00

samba-tool: add a function to cleanly demote a DC

samba-tool domain demote allow the local DC to properly demote against
Microsoft and Samba DC.
This commit is contained in:
Matthieu Patou
2011-12-04 23:00:57 +01:00
parent fc42b0ab41
commit f44e1a753a
2 changed files with 257 additions and 2 deletions

View File

@ -53,7 +53,7 @@ def drsuapi_connect(server, lp, creds):
drsuapiBind = drsuapi.drsuapi(binding_string, lp, creds)
(drsuapiHandle, bindSupportedExtensions) = drs_DsBind(drsuapiBind)
except Exception, e:
raise drsException("DRS connection to %s failed" % server, e)
raise drsException("DRS connection to %s failed: %s" % (server, e))
return (drsuapiBind, drsuapiHandle, bindSupportedExtensions)
@ -81,6 +81,26 @@ def sendDsReplicaSync(drsuapiBind, drsuapi_handle, source_dsa_guid, naming_conte
except Exception, estr:
raise drsException("DsReplicaSync failed %s" % estr)
def sendRemoveDsServer(drsuapiBind, drsuapi_handle, server_dsa_dn, domain):
"""
:param drsuapiBind: a drsuapi Bind object
:param drsuapi_handle: a drsuapi hanle on the drsuapi connection
:param server_dsa_dn: a DN object of the server's dsa that we want to demote
:param domain: a DN object of the server's domain
:raise drsException: if any error occur while sending and receiving the reply
for the DsRemoveDSServer
"""
try:
req1 = drsuapi.DsRemoveDSServerRequest1()
req1.server_dn = str(server_dsa_dn)
req1.domain_dn = str(domain)
req1.commit = 1
drsuapiBind.DsRemoveDSServer(drsuapi_handle, 1, req1)
except Exception, estr:
raise drsException("DsRemoveDSServer failed %s" % estr)
def drs_DsBind(drs):
'''make a DsBind call, returning the binding handle'''
bind_info = drsuapi.DsBindInfoCtr()