join a samba domain

Toff christophedeze at gmail.com
Mon Dec 22 16:17:55 CET 2008


hi,

I 'm trying to write a script to make my computer join a samba.

domeone have any idea ??


thanks regards,

*************************************************************************
# -*- coding: iso-8859-1 *-*

import win32com.client
import os,sys
import win32api
import impers
import socket
from win32com.client import GetObject
import wmi

def main():
	test()
	joindom()
def test():
	import wmi
	c = wmi.WMI()
	os = c.Win32_ComputerSystem
	for method_name in os.methods:
	  method = getattr(os, method_name)
	  print method

def joindom():
	#Joining a computer to a domain
	#=========================
	JOIN_DOMAIN             = 1
	ACCT_CREATE             = 2
	ACCT_DELETE             = 4
	WIN9X_UPGRADE           = 16
	DOMAIN_JOIN_IF_JOINED   = 32
	JOIN_UNSECURE           = 64
	MACHINE_PASSWORD_PASSED = 128
	DEFERRED_SPN_SET        = 256
	INSTALL_INVOCATION      = 262144
	strDomain   = "mydom"
	strPassword = "mydompw"
	strUser     = "admin"

	strComputer = socket.gethostname()
	print strComputer
	#objComputer = win32com.client.GetObject(r"winmgmts:
{impersonationLevel=Impersonate}!\\mypc\root
\cimv2:Win32_ComputerSystem.Name='mypc'")
	import wmi
	c = wmi.WMI()
	d = c.Win32_ComputerSystem
	d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")


if __name__=='__main__':
      main()
***********************************************************************



More information about the Python-list mailing list