Page 1 of 1 1
Topic Options
#182385 - 2007-11-09 10:45 AM Change terminal Services Profile attribute in W2003 AD
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Hi
I want to change Terminal Services attribute for a lot of people, (about 600.)
Found a vbscript that looks like this:
 Code:
 
Const Enabled = 1
Const Disabled = 0

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
 
objUser.TerminalServicesProfilePath = ""
objUser.TerminalServicesHomeDirectory = ""
objUser.TerminalServicesHomeDrive = ""
objUser.AllowLogon = Enabled
objUser.SetInfo


I want to do this in kix instead because I have all 600 username, profile path ... in an excel sheet. I will open the excel sheet and read each row with the username and then to the code above to clear the info. I have the excel code ready.
(We must have a backup plan, if i want to run this again and write back the same values to each user as they had from the beginning.)

Question 1: If a only know the username and dont know in which ou the user is in how can i do the ldap call ? The ldap call is dependent that I write the FQDN.

Question2: Can someone help me translate the vbscript into kixscript ?

Top
#182390 - 2007-11-09 12:23 PM Re: Change terminal Services Profile attribute in W2003 AD [Re: mima]
oneill Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 27
Loc: Australia
why don't you try admodify.net. It will do everything you want to and a hell of a lot more but with a GUI!

http://www.codeplex.com/admodify

Top
#182391 - 2007-11-09 12:58 PM Re: Change terminal Services Profile attribute in W2003 AD [Re: mima]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You should have found a few examples by searching on the object properties you are interested in.

Here is one I found which shows
  1. How to access the properties using KiXtart
  2. How to translate DOMAIN/USER -> LDAP

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=157365

Top
#182394 - 2007-11-09 01:21 PM Re: Change terminal Services Profile attribute in W2003 AD [Re: Richard H.]
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Hi Richard H

You are my favorite

Solved it with your help. Here is my code that can do all that I want.

 Code:
 
; Looping trough my Excel sheet to get username and others values

$username = "srvmik"

; Then the code to get FQDN
$userhome = TranslateName (3, "", 3, "@LDomain\$username", 1)
$userinfo = GetObject("LDAP://" + $userhome[0])

; Then set the parameters I want, either reset the value or 
; set a value from my excel sheet
$userinfo.TerminalServicesProfilePath = "\\server\share\srvmik"
$userinfo.SetInfo


; TranslateName function authored by Howard A. Bullock
Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText
$Error = 0
$ErrorText = ""
$ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate")
$Error = @error
$ErrorText = @serror
if $Error = 0
 $NameTranslate.Init ($InitType, $BindName)
 $Error = @error
 $ErrorText = @serror
 if $Error = 0
  $NameTranslate.Set ($LookupNameType, $LookupName)
  $Error = @error
  $ErrorText = @serror
  if $Error = 0
   $ReturnName = $NameTranslate.Get($ReturnNameType)
   $Error = @error
   $ErrorText = @serror
  endif
 endif
endif
$TranslateName = $ReturnName, $Error, $ErrorText
Endfunction

Top
#182415 - 2007-11-10 02:18 AM Re: Change terminal Services Profile attribute in W2003 AD [Re: mima]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Not the exact same thing, but here is some code I had from around April 2004
Makes changes to the actual Terminal Server

Here is a link to a site dedicated to Microsoft Terminal Server if wanted
http://www.msterminalservices.org/


 Code:
If Not @LogonMode
  Break On
Else
  Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $System, $Systems
$Systems = 'TERMSERVER01','TERMSERVER02','TERMSERVER03','TERMSERVER04'
For each $System in $Systems
  If $System
  	ResetTerminalServerSettings($System)
  EndIf
Next

Function ResetTerminalServerSettings(optional $System)
Dim $Key,$SetfInheritResetBroken,$SetfInheritMaxSessionTime,$SetfInheritMaxDisconnectionTime,
    $SetfInheritMaxIdleTime,$SetfResetBroken,$SetMaxDisconnectionTime,$SetMaxIdleTime,
    $SetMaxConnectionTime,$Remote
  $Remote = Join(Split($System, '\'), '', 3)
  $Remote = IIf($Remote <> '', '\\' + $Remote + '\', $Remote)
  $Key = 'HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
  $SetfInheritResetBroken          = WriteValue($Remote + $Key,'fInheritResetBroken',0,'REG_DWORD')
  $SetfInheritMaxSessionTime       = WriteValue($Remote + $Key,'fInheritMaxSessionTime',0,'REG_DWORD')
  $SetfInheritMaxDisconnectionTime = WriteValue($Remote + $Key,'fInheritMaxDisconnectionTime',0,'REG_DWORD')
  $SetfInheritMaxIdleTime          = WriteValue($Remote + $Key,'fInheritMaxIdleTime',0,'REG_DWORD')
  $SetfResetBroken                 = WriteValue($Remote + $Key,'fResetBroken',1,'REG_DWORD')
  $SetMaxConnectionTime            = WriteValue($Remote + $Key,'MaxConnectionTime',0,'REG_DWORD')
  $SetMaxDisconnectionTime         = WriteValue($Remote + $Key,'MaxDisconnectionTime',60000,'REG_DWORD')
  $SetMaxIdleTime                  = WriteValue($Remote + $Key,'MaxIdleTime',1800000,'REG_DWORD')
EndFunction


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 1577 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

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