[python-win32] WTS user object setup problem using win32com.client

Larry Bates lbates@syscononline.com
Wed, 19 Mar 2003 13:11:17 -0600


I need to set up users on NT server from information stored in database.
So far I have been successful in creating the User/Password/Comments, etc.
using the win32Net.NetUserAdd functions.  Unfortunately there doesn't
appear to be any way to set the options that I want using that method.

I need to set items that are found in the Environment tab under
User-Properties.
The options are:

TerminalServicesInitialProgram
TerminalServicesWorkDirectory

I found an online article and combined it with some python code I found
that looked like it should work, but it doesn't.  I was hoping someone could
take a quick look to see why this is not working.

Thanks in advance,
Larry

lbates@syscononline.com

#---------------------------------------------
from win32com.client import GetObject
import sys

USERobj=GetObject("LDAP://syscon.com/CN=lab,CN=Users,DC=syscon,DC=com")

print "setting User object attributes"

#obj.ConnectClientDrivesAtLogon=1
#obj.ConnectClientPrintersAtLogon=1
#obj.DefaultToMainPrinter=1
obj.TerminalServicesInitialProgram="notepad.exe"
obj.TerminalServicesWorkDirectory="tmp"
print "saving User object"
obj.SetInfo()


Traceback (most recent call last):
  File
"C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\python22\SYNCusers\LDAP_test1.py", line 12, in ?
  File "C:\Python22\Lib\site-packates\win32com\client\dynamic.py", line 482,
in __setattr__
    raise AttributeError, "Property '%s.%s' can not be set." %
(self._username, attr)
AttributeError: Property 'LDAP://syscon.com/CN=lab,CN=Users,DC=syscon,
  DC=com.TerminalServicesInitialProgram' can not be set.