pyad
pyad copied to clipboard
Could not rename a computer name
Code: computer = adcomputer.ADComputer.from_cn('WS-490')
computer.rename('WS-4900')
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\utility\test.py", line 25, in
Hrm. Is the computer in an OU or what's its actual DN?
things that would also be helpful would be:
print ADObject.from_dn(computer.parent_container_path, options = computer._make_options()).type
This computer DN is: CN=WS-490,CN=Computers,DC=dc2k8,DC=wingra,DC=com. And return type is "container"
"In a default installation of an Active Directory domain, user accounts, computer accounts, and groups are put in CN=objectclass containers instead of being put in a more desirable organizational unit class container. Similarly, user accounts, computer accounts, and groups that were created by using earlier-version APIs are put in the CN=Users and CN=computers containers."
This is fixable easily enough, will post a patch in a minute to test.
Can you try installing 0.5.12 from github and try again?
ok
After upgraded, Computer name renamed, but show some error:
File "C:\Python27\lib\site-packages\pyad\adobject.py", line 442, in rename self.__set_gc_adsi_obj() File "C:\Python27\lib\site-packages\pyad\adobject.py", line 215, in __set_gc_adsi_obj self._gc_adsi_obj = self.adsi_provider.GetObject('', path) File "<COMObject ADsNameSpaces>", line 2, in GetObject pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Active Directory', u'There is no such object on the server.\r\n', None, 0, -2147016656), None)
Does the computer actually get renamed?
Yes, renamed.
Is the GC on a different server than the DC to which you're connected?
What it looks like is that this isn't propagating to the global catalog quickly enough and when pyad attempts to get the new object, it fails because the GC still thinks it's named the old thing. There isn't a ton you can do here other than try to allow some time to for it to propagate. There's a small sleep in the code base that should help this along, but isn't high enough in this particularly environment.
Not a great solution other than sleep and try again.
My test env is Windows server 2008R2 Enterprise, Only one machine(as Domain server).
I try to delay the time(in rename method: time.sleep) to 10s, error is the same one.
Is there a solution to this problem? It also happens with the function move.