[python-win32] Get DN of Computer (OU Located)
Tim Golden
mail at timgolden.me.uk
Thu Nov 5 13:20:26 CET 2009
Jose Noto wrote:
> Good morning,
>
> I'm trying to create a script where I need to know in witch OU / DN the
> computer is located from just knowing its hostname and I can not figure
> it out or find anything about it on the net. Does anyone know how to do it?
>
> On VBScript would be something like this:
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strComputer = objSysInfo.ComputerName
Translating literally:
<code>
import win32com.client
sys_info = win32com.client.Dispatch ("ADSystemInfo")
computer = sys_info.ComputerName
print computer
</code>
TJG
More information about the python-win32
mailing list