Page 1 of 1 1
Topic Options
#85106 - 2002-02-12 06:08 PM Terminal Server options in ADSI
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
I have some questions about COM / ADSI scripting. I'm building a nice
tool, based on the incredible and easy to use KiXtart, together with
KiXGui. The Tool, called Extended Usermanager, should easily add new
user accounts to my domain, with all the default user options together
with an email account. When it's there I will publish it for everyone
else, for all the creativity everyone else gave me.

The Problem;
I can't find the string in ADSI that adds the Terminal Server sections
known in Usermanager for Domains. Like the Profile and Home Directory. Ofcourse I can use addusers.exe
provided with NT 5.0 RK with the /t switch, but i don't want to rope
everything together. The ADSI SDK doesn't tell any thing about this part.

Can anyone help me out on this?

Ryan

Top
#85107 - 2002-02-13 12:57 AM Re: Terminal Server options in ADSI
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
You are in luck. I have done this just recently. Unfortunately ADSI does not do TSE stuff, but here is something that does..

Firstly, read this post and greetz to all involved getting that working

Secondly, here is the code that I am currently using to set the terminal server profile path

VBScript

code:

function TSProfilePath(sUserID, sProfilePath) '......................................................Set TSE Profile
on error resume next ' continue on errors
set oTSConfig=CreateObject("UserConfig.TSUserConfig") ' create a Terminal Server settings object
oTSConfig.UserName=sUserID ' select user ID
oTSConfig.Domain=sNTDomain ' select NT Domain
zTemp=oTSConfig.SetUserConfig(15, sProfilePath) ' set profile path for user
TSProfilePath=err.number & "," & err.description ' return with the status
end function

KiXtart 4.02

code:

function TSProfilePath($sUserID, $sProfilePath) '......................................................Set TSE Profile
$oTSConfig=CreateObject("UserConfig.TSUserConfig") ' create a Terminal Server settings object
$oTSConfig.UserName=$sUserID ' select user ID
$oTSConfig.Domain=$sNTDomain ' select NT Domain
$zTemp=$oTSConfig.SetUserConfig(15, $sProfilePath) ' set profile path for user
$TSProfilePath=@error & "," & @serror ' return with the status
endfunction


and thirdly, here is where you can download the .DLL you need to make all this work. As usual, use REGSVR32 to register.

cj

p.s. I have not tested the KiX code, I just converted it from my VBScript code.

Top
#85108 - 2002-02-13 02:17 PM Re: Terminal Server options in ADSI
Mark Bennett Offline
Getting the hang of it

Registered: 2001-10-10
Posts: 70
Alternatively I found a 3rd party utility called TSCMD that allows you to manipulate all of the TS parameters from the command line. I found it really easy to use within KIX (shell out), and didn't need to learn about ADSI or VB objects.
Mark

Top
#85109 - 2002-02-13 02:55 PM Re: Terminal Server options in ADSI
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Thanx man!

It's not exactly what i'm looking for , but as U said, ADSI hasn't got the options 4 TS.

Till then I'll try it ur way!

Thanx 4 ur support and links!

Ryan

Top
#85110 - 2002-02-13 03:11 PM Re: Terminal Server options in ADSI
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Hello again,

Maybe a nice detail, but with the program addusers.exe shiped with Win2k Resource Kit there's also a nice option for the Terminal Server users.

shell '%comspec% /c addusers /c "$importFile" /t $yourDomain'

/c creates an account.
/d dumps all sam accounts.
/e erase an account.
$importFile is the comma seperated account file.
/t for terminal server use and options.
$yourDomain should b ur domain.

try this:
$yourDomain = "Domain"
$dumpFile = "%temp%\samDump.log"

shell '%comspec% /c addusers /d "$importFile" /t $yourDomain'

Open the file created in ur temp dir and u'll c all the options.

But i've lost my hart in COM scripting, so that's what i prefer.

Ryan

Top
#85111 - 2002-02-18 02:06 AM Re: Terminal Server options in ADSI
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Ok.. If you need, I can get you the DLL..

Untested, but should work.

code:

; -- Originally discussed at - http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002825
; -- Thanks ceej for pointing out the solution!
; -- Perms and stuff discussed at - http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002078&p=
; -- Thanks Shawn for Perms "port over!"
;Use the wtsapi32.dll from VBS
; VB Constant declarations for WTS_CONFIG_CLASS
$WTSUserConfigInitialProgram = &H0 ; string
$WTSUserConfigWorkingDirectory = &H1 ; string
$WTSUserConfigfInheritInitialProgram = &H2 ; DWORD
$WTSUserConfigfAllowLogonTerminalServer = &H3 ; DWORD
; Timeout settings
$WTSUserConfigTimeoutSettingsConnections = &H4 ; DWORD
$WTSUserConfigTimeoutSettingsDisconnections = &H5 ; DWORD
$WTSUserConfigTimeoutSettingsIdle = &H6 ; DWORD
; Client device settings
$WTSUserConfigfDeviceClientDrives = &H7 ; DWORD
$WTSUserConfigfDeviceClientPrinters = &H8 ; DWORD
$WTSUserConfigfDeviceClientDefaultPrinter = &H9 ; DWORD
; Connection settings
$WTSUserConfigBrokenTimeoutSettings = &HA ; DWORD
$WTSUserConfigReconnectSettings = &HB ; DWORD
; Modem settings
$WTSUserConfigModemCallbackSettings = &HC ; DWORD
$WTSUserConfigModemCallbackPhoneNumber = &HD ; string
; Shadow settings
$WTSUserConfigShadowingSettings = &HE ; DWORD
; User Profile settings
$WTSUserConfigTerminalServerProfilePath = &HF ; string
; Terminal Server home directory
$WTSUserConfigTerminalServerHomeDir = &H10 ; string
$WTSUserConfigTerminalServerHomeDirDrive = &H11 ; string
$WTSUserConfigfTerminalServerRemoteHomeDir = &H12 ; DWORD
;*************************************************************************
;*************************************************************************
$TSCFG= CreateObject("UserConfig.TSUserConfig")
$oFs = CreateObject("Scripting.FileSystemObject")
; -- Grab the current domain you are running this script from
$WshNetwork = WScript.CreateObject("WScript.Network")
TSCFG.Domain = WshNetwork.UserDomain
; -- If you want to manually set this, uncomment the next line and comment the previous two
$TSCFG.Domain = "MYDOMAIN"
;TSCFG.Domain = InputBox("Type The Domain name")
; -- Set the server where the shares reside
$ShareServer = "SHARESERVER"
$Debugger = "_No" ;If you want to see visual results, set this to be "_Yes"
? "Type a User Name"
GETS $TSCFG.UserName
If $TSCFG.UserName = ""
? "No UserID input provided. Stopping script now."
exit
EndIf
;We need to check and if need be create some folders for this user..
; Capture the name of the server are you adding the share to
TextShare = "\\" + $ShareServer + "\D" + Chr(36)
; Setting the user$ variable - jdoe$ - Hidden shares don't show when browsing to a server
$TextUserN = $TSCFG.UserName + Chr(36)
; Setting the user1$ variable - jdoe1$ - Hidden shares don't show when browsing to a server
; Why are we using a jdoe1$ ?? This server has other shared drives for local Corporate User too.
$TextUserNM = TSCFG.UserName + "1" + Chr(36) ; Created for home_dir
; Path for user folders
$Homedir = $TextShare + "\Citrix_Homedir"
$Profiles = $TextShare + "\Citrix_Profiles"
$ Now let's create a variable to work with - \\SERVER\users\jdoe
$ Directory to save
$UserProfileDir = $Profiles + "\" + $TSCFG.UserName
; Check existence for folder
If $Debugger = "_Yes"
If $oFs.FolderExists($UserProfileDir)
?"The citrix profiles folder " + UserProfileDir + " already exists."
endif
endif
$UserHomeDir = $Homedir + "\" + $TSCFG.UserName
; Check existence for folder
If $Debugger = "_Yes"
If $oFs.FolderExists($UserHomeDir)
?"The citrix Home_dir folder " + UserHomeDir + " already exists and we are continuing."
endif
endif
; Create folder Profiles
If Not $oFs.FolderExists($UserHomeDir) $oFs.CreateFolder $UserHomeDir
If Not $oFs.FolderExists($UserProfileDir) $oFs.CreateFolder $UserProfileDir
; Create share
$FservObj = GetObject("WinNT://" + $ShareServer + "/lanmanserver")
If $oFs.FolderExists("\\" + $ShareServer + "\" + $TextUserNM)
If $Debugger = "_Yes"
?"The share \\" + $ShareServer + "\" + TextUserNM + " already exists." + " Continuing..."
endif
else
; Create the share for the server jdoe1$
$newshare = $FservObj.create("fileshare",$TextUserNM)
; Set the path for the share on the server - D:\Users
$newshare.path = "D:\Citrix_Homedir\" + $TSCFG.UserName
$newshare.setinfo
?"The folders for " & TSCFG.UserName & " and share have been created."
endif

;-- Query the information for debugging - uncomment the next three lines to see this
;MsgBox TSCFG.QueryUserConfig(WTSUserConfigTerminalServerProfilePath)
;MsgBox TSCFG.QueryUserConfig(WTSUserConfigTerminalServerHomeDir)
;MsgBox TSCFG.QueryUserConfig(WTSUserConfigTerminalServerHomeDirDrive)
;-- Set some information
$TSCFG.SetUserConfig $WTSUserConfigfAllowLogonTerminalServer, 1
$TSCFG.SetUserConfig $WTSUserConfigTerminalServerProfilePath , "\\" + $ShareServer + "\CITRIX_PROFILES\" + $TSCFG.UserName
$TSCFG.SetUserConfig $WTSUserConfigTerminalServerHomeDirDrive , "H:"
$TSCFG.SetUserConfig $WTSUserConfigTerminalServerHomeDir , "\\" + ShareServer + "\" + TSCFG.UserName + "1" + chr(36)
?"The User Profile and Home Drive Server have been set for " + $TSCFG.UserName + "and may take up to an hour to show up."
l = 0
;*** show all settings - documentation; see below!
;For $x = 0 To 18
; ?"setting " + x + " = " + $TSCFG.QueryUserConfig($x)
;Next
; --- Example Code and settings you can use..
;*** change a few settings:
;$TSCFG.SetUserConfig $WTSUserConfigWorkingDirectory , "c:\workdir"
;$TSCFG.SetUserConfig $WTSUserConfigInitialProgram , "startup.exe"
;*************************************************************************
;*************************************************************************

;*** http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/tsref_9z76.a sp
;WTSUserConfigInitialProgram
;A null-terminated string containing the path of the initial program that Terminal Services
;runs when the user logs on.
;If the WTSUserConfigfInheritInitialProgram value is 1, the initial program can be any
;program specified by the client.

;WTSUserConfigfInheritInitialProgram
;WTSUserConfigfInheritInitialProgram value is 1, the initial program can be any program
;specified by the client.

;WTSUserConfigWorkingDirectory
;A null-terminated string containing the path of the working directory for the initial
;program.
;WTSUserConfigfInheritInitialProgram
;A value that indicates whether the client can specify the initial program. Value Meaning
;0 The client cannot specify the initial program. The WTSUserConfigInitialProgram string
;indicates the initial program. If you specify a user's initial program, that's the only
;program they can run; terminal server logs off the user when the user exits that program.
;1 The client can specify the initial program.

;WTSUserConfigfAllowLogonTerminalServer
;A value that indicates whether the user account is permitted to log on to a terminal server.
;Value Meaning
;0 The user cannot logon.
;1 The user can logon.

;WTSUserConfigTimeoutSettingsConnections
;A DWORD value that specifies the maximum connection duration, in milliseconds. One minute
;before the connection timeout interval expires, the user is notified of the pending
;disconnection. The user's session is disconnected or terminated depending on the
;WTSUserConfigBrokenTimeoutSettings value. Every time the user logs on, the timer is reset.
;A value of zero indicates the connection timer is disabled.
;WTSUserConfigTimeoutSettingsDisconnections
;A DWORD value that specifies the maximum duration, in milliseconds, that a terminal
;server retains a disconnected session before the logon is terminated. A value of zero
;indicates the disconnection timer is disabled.
;WTSUserConfigTimeoutSettingsIdle
;A DWORD value that specifies the maximum idle time, in milliseconds. If there is no
;keyboard or mouse activity for the specified interval, the user's session is disconnected
;or terminated depending on the WTSUserConfigBrokenTimeoutSettings value. A value of zero
;indicates the idle timer is disabled.
;WTSUserConfigfDeviceClientDrives
;Citrix ICA clients: A value that indicates whether the terminal server automatically
;reestablishes client drive mappings at logon. Value Meaning
;0 The server does not automatically connect to previously mapped client drives.
;1 The server automatically connects to previously mapped client drives at logon.

;WTSUserConfigfDeviceClientPrinters
;RDP 5.0 clients and Citrix ICA clients: A value that indicates whether the terminal server
;automatically reestablishes client printer mappings at logon. Value Meaning
;0 The server does not automatically connect to previously mapped client printers.
;1 The server automatically connects to previously mapped client printers at logon.

;WTSUserConfigfDeviceClientDefaultPrinter
;RDP 5.0 clients and Citrix ICA clients: A value that indicates whether the client printer
;is the default printer. Value Meaning
;0 The client printer is not the default printer.
;1 The client printer is the default printer.

;WTSUserConfigBrokenTimeoutSettings
;A value that indicates what happens when the connection or idle timers expire or when a
;connection is lost due to a connection error. Value Meaning
;0 The session is disconnected.
;1 The session is terminated.

;WTSUserConfigReconnectSettings
;A value that indicates how a disconnected session for this user can be reconnected.
;Value Meaning
;0 The user can log on to any client computer to reconnect to a disconnected session.
;Note that sessions started at clients other than the system console cannot be connected
;to the system console, and sessions started at the system console cannot be disconnected.
;1 The user can reconnect to a disconnected session by logging on to the client computer
;used to establish the disconnected session. If the user logs on from a different client
;computer, the user gets a new logon session.

;WTSUserConfigModemCallbackSettings
;Citrix ICA clients: A value that indicates the configuration for dialup connections in which
;the terminal server hangs up and then calls back the client to establish the connection.
;Value Meaning
;0 Callback connections are disabled.
;1 The server prompts the user to enter a phone number and calls the user back at that phone
;number. You can use the WTSUserConfigModemCallbackPhoneNumber value to specify a default
;phone number.
;2 The server automatically calls the user back at the phone number specified by the
;WTSUserConfigModemCallbackPhoneNumber value.

;WTSUserConfigModemCallbackPhoneNumber
;Citrix ICA clients: A null-terminated string containing the phone number to use for callback
;connections.
;WTSUserConfigShadowingSettings
;RDP 5.0 clients and Citrix ICA clients: A value that indicates whether the user session can
;be shadowed. Shadowing allows a user to remotely monitor the on-screen operations of another user.
;Value Meaning
;0 Disable
;1 Enable input, notify
;2 Enable input, no notify
;3 Enable no input, notify
;4 Enable no input, no notify

;WTSUserConfigTerminalServerProfilePath
;A null-terminated string containing the path of the user's profile for terminal server logon.
;The directory the path identifies must be created manually, and must exist prior to the logon.
;WTSSetUserConfig will not create the directory if it does not already exist.
;WTSUserConfigTerminalServerHomeDir
;A null-terminated string containing the path of the user's home directory for terminal server
;logon. This string can specify a local path or a UNC path (\\machine\share\path). See
;WTSUserConfigfTerminalServerRemoteHomeDir.
;WTSUserConfigTerminalServerHomeDirDrive
;A null-terminated string containing a drive specification (a drive letter followed by a colon)
;to which the UNC path specified in the WTSUserConfigTerminalServerHomeDir string is mapped.
;See WTSUserConfigfTerminalServerRemoteHomeDir.
;WTSUserConfigfTerminalServerRemoteHomeDir
;A value that indicates whether the user's home directory for terminal server logon is a local
;path or a mapped drive letter. Note that this value cannot be used with WTSSetUserConfig.
;Value Meaning
;0 The WTSUserConfigTerminalServerHomeDir string contains the local path of the user's terminal
;server logon home directory.
;1 The WTSUserConfigTerminalServerHomeDir string contains the UNC path of the user's terminal
;server logon home directory, and the WTSUserConfigTerminalServerHomeDirDrive string contains
;a drive letter to which the UNC path is mapped.


Thanks!

- Kent

[ 18 February 2002: Message edited by: kdyer ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#85112 - 2002-02-22 04:50 AM Re: Terminal Server options in ADSI
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Hiya,

You can get the DLL from here

cj

Top
#85113 - 2002-02-22 04:06 PM Re: Terminal Server options in ADSI
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
ceej,

Thanks for posting the DLL.

- Kent

[ 22 February 2002: Message edited by: kdyer ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.06 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org