#101177 - 2003-05-22 07:39 AM
Microsoft releases ADSI Scriptomatic
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
17-May-03 Microsoft releases ADSI Scriptomatic. The ADSI Scriptomatic is designed to help you write ADSI scripts; that is, scripts that can be used to manage Active Directory. The ADSI Scriptomatic also teaches you an important point about ADSI scripting: like WMI, there are consistent patterns to ADSI scripts. Download it from here...
BTW.. System Requirements Supported Operating Systems: Windows 2000, Windows Server 2003, Windows XP
This is not the WMI version/edition - New WMI Tool at Microsoft - Scriptomatic Tool
Or the KiXtart incarnation thereof.
Picked this up at - Windows-Script
Thanks,
Kent
|
|
Top
|
|
|
|
#101182 - 2003-05-23 08:34 AM
Re: Microsoft releases ADSI Scriptomatic
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Where did this script go?
I want one!
Kent
|
|
Top
|
|
|
|
#101183 - 2003-05-23 05:04 PM
Re: Microsoft releases ADSI Scriptomatic
|
ChristopheM
Hey THIS is FUN
   
Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
|
hi,
it's a little big but here is the code
the original .hta source can be downloaded from Microsoft Site
code:
;******************************************************************** ; File: EzADscripto.kix ; Created: May 2003 ; Version: 1.0 ; Author: Christophe MELIN ; Description: Learning tool. Generates ADSI scripts to ; demonstrate the fundamental ; ADSI tasks, Create, Write, Read, and Modify. ; ;******************************************************************** ; converted from EzADscripto.hta (December 2002) ; ; Author: The Scripting Guys - Dean Tsaltas, Bob Wells, ; Greg Stemp, and Ethan Wilansky. ; Initial concept from ScriptoMatic by Dean Tsaltas ; and Greg Stemp ; ; Copyright (C) 2003 Microsoft Corporation ;********************************************************************
Global $true, $false
$vbTab = chr(9) $true = 1 $false = 0
;--------------------------------------------------------------------------- ; Main Form ;--------------------------------------------------------------------------- $frmMain = CreateObject("Kixtart.Form") $frmMain.Size = 750,580 ;$frmMain.SysMenu = 0 ; Disable the sysmenu. Prevents users from closing forms $frmMain.Text = "ADSI Scriptomatic for KIX" $frmMain.Center
$TaskSelectPulldown = $frmMain.ComboBox $TaskSelectPulldown.List = "Select a task","Create an object","Write an object","Read an object","Delete an object" $TaskSelectPulldown.Top = 10 $TaskSelectPulldown.Left = 10 $TaskSelectPulldown.Bottom = $frmMain.ClientHeight / 2 $TaskSelectPulldown.width = 150 $TaskSelectPulldown.ListIndex = 0 $TaskSelectPulldown.TabStop = 1 $TaskSelectPulldown.Style = 1 $TaskSelectPulldown.OnClick = "$=TaskSelectPulldownCheck()"
$classesPulldown = $frmMain.ComboBox $classesPulldown.List = "Select an object","user","computer","contact","group","organizationalUnit" $classesPulldown.Top = 10 $classesPulldown.Left = $TaskSelectPulldown.width+10 $classesPulldown.Bottom = $frmMain.ClientHeight / 2 $classesPulldown.width = $TaskSelectPulldown.width $classesPulldown.ListIndex = 0 $classesPulldown.TabStop = 1 $classesPulldown.Style = 1 $classesPulldown.Enabled = $false $classesPulldown.OnClick = "$=TaskSelectPulldownCheck()"
$runBtn = $frmMain.Button $runBtn.left = $classesPulldown.right+10 $runBtn.top = $TaskSelectPulldown.top $runBtn.width = 50 $runBtn.height = 22 $runBtn.text = "run" $runBtn.OnClick = "RunScript()"
$saveBtn = $frmMain.Button $saveBtn.left = $runBtn.right $saveBtn.top = $TaskSelectPulldown.top $saveBtn.width = 50 $saveBtn.height = $runBtn.height $saveBtn.text = "save" $saveBtn.OnClick = "SaveScript()"
$loadBtn = $frmMain.Button $loadBtn.left = $saveBtn.right $loadBtn.top = $TaskSelectPulldown.top $loadBtn.width = 50 $loadBtn.height = $runBtn.height $loadBtn.text = "load" $loadBtn.OnClick = "OpenScript()"
$exitBtn = $frmMain.Button $exitBtn.left = $loadBtn.right $exitBtn.top = $TaskSelectPulldown.top $exitBtn.width = 50 $exitBtn.height = $runBtn.height $exitBtn.text = "exit" $exitBtn.OnClick = "QuitScript()"
$lblImptNote = $frmMain.Label $lblImptNote.top = $TaskSelectPulldown.bottom + 10 $lblImptNote.left = 10 $lblImptNote.width = $frmMain.scalewidth - (2 * $lblImptNote.left) $lblImptNote.height = $frmMain.scaleheight - 10 - $lblImptNote.top
$lblnotesbutton = $frmMain.label $lblnotesbutton.top = $TaskSelectPulldown.bottom + 5 $lblnotesbutton.left = 10 $lblnotesbutton.width = $frmMain.scalewidth - (2 * $lblnotesbutton.left) $lblnotesbutton.height = 20 $lblnotesbutton.caption = "" $lblnotesbutton.OnClick = "ImptDialog()"
$lblnotesbuttonrun = $frmMain.label $lblnotesbuttonrun.top = $lblnotesbutton.bottom + 5 $lblnotesbuttonrun.left = 10 $lblnotesbuttonrun.width = $frmMain.scalewidth - (2 * $lblnotesbutton.left) $lblnotesbuttonrun.height = 20 $lblnotesbuttonrun.caption = "" $lblnotesbuttonrun.OnClick = "RunDialog()"
$Message = $frmMain.TextBox $Message.FontSize = 10 $Message.Top = $lblnotesbuttonrun.bottom + 5 $Message.Left = 10 $Message.Right = $frmMain.scalewidth - 10 $Message.height = $frmMain.scaleheight - 10 - $message.top $Message.MultiLine = $true $Message.WordWrap = $false $Message.BorderStyle = 0 $Message.ScrollBars = 3 $Message.FontName = "Courier New" $Message.WordWrap = $false
$=InitialUIState()
$frmMain.Center $frmMain.Show
While $frmMain.Visible $=Execute($frmMain.DoEvents) Loop
EXIT 0
;************************************************************************** ; These subroutines control the state of the user interface. Each ; routine includes descriptive text. ;************************************************************************** ;This is the state the HTA UI elements should be in before anything is selected. function InitialUIState $TaskSelectPulldown.enabled = $true $runbtn.enabled = $false $savebtn.enabled = $false $classesPulldown.ListIndex = 0 $classesPulldown.enabled = $false
$lblImptNote.visible = $true
$message.visible = $false $message.text = ""
$lblnotesbutton.visible = $false $lblnotesbuttonrun.visible = $false
$lblImptNote.caption = "EzAD Scriptomatic is an ADSI Scripting learning tool." + @crlf + "The tool creates example scripts that read, write and" + @crlf + "modify Active Directory data. To successfully run" + @crlf + "scripts created with EzAD Scriptomatic, you must:" + @crlf + "1. have Administrator access to Active Directory, and" + @crlf + "2. be logged on to the target Active Directory domain.@crlf" + @crlf + "You should not run scripts created with EzAD Scriptomatic" + @crlf + "against a production domain without first testing the" + @crlf + "scripts in your designated testing environment." endfunction
;If the operator selects a different task, reset the UI in preparation for selecting a class. function ResetForClassesPullDown $classesPulldown.enabled = $true $message.text= "" $message.visible= $false $lblImptNote.visible = $true $lblnotesbutton.visible = $false $lblnotesbuttonrun.visible = $false endfunction
;If the $TaskSelectPulldown is not set to Select a task enable the $classesPulldown. Otherwise, disable the $classesPulldown. function TaskSelectPulldownCheck if ($TaskSelectPulldown.ListIndex="0") $=InitialUIState return endif $=ResetForClassesPullDown if ($ClassesPulldown.ListIndex="0") return endif Select Case $TaskSelectPulldown.ListIndex="1" $=ResetForClassesPullDown $=CreateCreateScript
Case $TaskSelectPulldown.ListIndex="2" $=ResetForClassesPullDown $=CreateWriteScript
Case $TaskSelectPulldown.ListIndex="3" $=ResetForClassesPullDown $=CreateReadScript
Case $TaskSelectPulldown.ListIndex="4" $=ResetForClassesPullDown $=CreateDeleteScript EndSelect
;Enable the Running This Script, Run, and Save buttons. $=FinalUIState endfunction
;Once a script is generated, enable the Running This Script, Run, and Save buttons. function FinalUIState $lblImptNote.visible = $false $message.visible= $true $Message.SelStart = 0 $Message.SelLength = 0
$lblnotesbutton.visible = $true $lblnotesbuttonrun.visible = $true
$lblnotesbuttonrun.caption="Read this before running the " + lcase($TaskSelectPulldown.Text) + " - " + $classesPulldown.Text + " script" $runBtn.enabled = $true $savebtn.enabled = $true endfunction
;*************************************************************************** ; When the operator presses the Run button, we use the WshShell $object's Run ; method to run the code currently in the textarea under cscript.exe. we use ; cmd.exe's /k parameter to ensure the command window remains visible after ; the script has finished running. ;*************************************************************************** function RunScript() $strTmpName = "%temp%\temp_script.kix" if DoSave($strTmpName) Shell("cmd /k cscript.exe $strTmpName") endif endfunction
;*************************************************************************** ; When the operator presses the Save button, we present them with an InputBox ; and force them to give us the full path to where they'd like to the save ; the script that is currently in the textarea. The user is probably quite ; upset with our laziness here....and who can blame them? ;***************************************************************************
function SaveScript() $strSaveFileName="%temp%\toto.kix" ; Do the save $=DoSave( $strSaveFileName ) return
$form=createobject("Kixtart.Form") $SaveDir = @CurDir CD 'C:\util' $value=$form.FileSaveDialog( "Enregistrer sous...", "", "Nom du document", "scripts kix|*.kix|fichiers texte|*.txt|tous les fichiers|*.*", 0 )
CD $SaveDir If $Value $strSaveFileName=$value ; Do the save $=DoSave( $strSaveFileName ) EndIf $form=Nothing endfunction
;*************************************************************************** ; When the operator presses the Open button, we present them with an InputBox ; and force them to give us the full path to the script they'd like to open. ; This is, of course, rather wonky - but it's meant to be. ;***************************************************************************
function OpenScript() $form=createobject("Kixtart.Form") $OpenDir = @CurDir CD '%TEMP%' $value=$form.FileOpenDialog( "Ouvrir...", "", "Nom du document", "scripts kix|*.kix|fichiers texte|*.txt|tous les fichiers|*.*", 0 )
CD $OpenDir If $Value $strOpenFileName=$value ; Load the file $handle = freefilehandle() $err = open($handle,$strOpenFileName,2) if $err=0 $strHTML = "" $line = ReadLine($handle) WHILE @ERROR = 0 $strHTML = $strHTML + $line + @crlf $line = ReadLine($handle) LOOP $message.text = $strHTML $=close($handle)
$runBtn.enabled = $true $savebtn.enabled = $true endif EndIf $form=Nothing $=FinalUIState() $lblnotesbutton.visible = $false $lblnotesbuttonrun.visible = $false endfunction
;*************************************************************************** ; When the operator presses the Quit button, the file where we've been storing ; the scripts gets deleted and the main window closes. ;***************************************************************************
function QuitScript() DEL "temp_script.kix" Quit 0 endfunction
;************************************************************************** ; These functions are called by other functions that generate the code for ; the Read an $object task. Each function in this section generates code ; based on attribute definitions. ;************************************************************************** Function strReadCodeSV($strPageName,$arrName) $strHTML = "" $strHTML = $strHTML + '? "** $strPageName Properties Page : Single-Valued Attributes **"' + @crlf For each $attrib in $arrName if $attrib $kixattrib = FormatKixObjName($attrib) $strHTML = $strHTML + '$$str$kixattrib = $$objItem.Get("$attrib")' + @crlf $strHTML = $strHTML + '? "$attrib : $$str$kixattrib"' + @crlf endif Next $strReadCodeSV = $strHTML + @crlf EndFunction
Function strReadCodeMV($strPageName,$arrName) $strHTML = "" $strHTML = $strHTML + '? "** $strPageName Properties Page : Multi-Valued Attributes **"' + @crlf For Each $attrib in $arrName if $attrib $strHTML = $strHTML + '$$str$attrib = $$objItem.GetEx("$attrib")' + @crlf $strHTML = $strHTML + '? "$attrib : "' + @crlf $strHTML = $strHTML + 'For Each $$Item in $$str' + $attrib + @crlf $strHTML = $strHTML + $vbTab + '? $$Item' + @crlf $strHTML = $strHTML + 'Next' + @crlf endif Next $StrReadCodeMV = $strHTML + @crlf EndFunction
;For reading attributes stored as integers containing bit flags Function IntReadCode($strPageName,$attrib,$arrConstant,$arrValue) $strHTML = "" $strHTML = $strHTML + '? "** $strPageName Properties Page : " + $attrib + " attribute **"' + @crlf $strHTML = $strHTML + '$$objHash = CreateObject("Scripting.Dictionary")' + @crlf $i = 0 For Each $constant in $arrConstant if $constant $strHTML = $strHTML + '$$=$$objHash.Add( "$constant", $arrValue[$i])' + @crlf $i = 1 + $i endif Next $strHTML = $strHTML + '$$int$attrib = $$objItem.Get("$attrib")' + @crlf $strHTML = $strHTML + 'For Each $$Key in $$objHash.Keys' + @crlf $strHTML = $strHTML + $vbTab + 'If $$objHash[$$Key] & $$int$attrib' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "$$Key is enabled."' + @crlf $strHTML = $strHTML + $vbTab + 'Else' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "$$Key is disabled."' + @crlf $strHTML = $strHTML + $vbTab + 'EndIf' + @crlf $strHTML = $strHTML + "Next" $IntReadCode = $strHTML + @crlf EndFunction
Function ReadPropertiesSimple($strPageName,$interfaceName,$arrProp) $strHTML = "" $strHTML = $strHTML + '? "** $strPageName Properties Page : " + $interfaceName + " interface **"' + @crlf For Each $prop in $arrProp if $prop $strHTML = $strHTML + '? " $prop : " + $$objItem.$prop' + @crlf endif Next $ReadPropertiesSimple = $strHTML + @crlf EndFunction
;************************************************************************** ; These functions are called by other functions that generate the code for ; the Write an $object task. Each function in this section generates code ; based on attribute definitions. ;************************************************************************** Function strWriteCodeSV($strPageName,$arrName,$strValue) $strHTML = "" If $strValue = "VALUE" $strHTML = $strHTML + '? "** $strPageName Properties Page : writing Single-Valued Attributes **"' + @crlf Else $strHTML = $strHTML + ';See Script Notes for information on setting this value.' + @crlf $strHTML = $strHTML + '? "** $strPageName Properties Page : non standard valued **"' + @crlf EndIf For each $attrib in $arrName if $attrib $strHTML = $strHTML + '$$objItem.Put( "$attrib", "$strValue")' + @crlf $strHTML = $strHTML + '$$objItem.SetInfo()' + @crlf endif Next $strWriteCodeSV = $strHTML + @crlf EndFunction
Function strWriteCodeMV($strPageName,$arrName,$strValue) $strHTML = "" If $strValue = "VALUE" $strHTML = $strHTML + '? "** $strPageName Properties Page : writing Multi-Valued Attributes **"' + @crlf Else $strHTML = $strHTML + ';See Script Notes for information on setting this value.' + @crlf $strHTML = $strHTML + '? "** $strPageName Properties Page : non standard Multi-Valued Attributes **"' + @crlf EndIf For each $attrib in $arrName if $attrib $strHTML = $strHTML + '$$objItem.PutEx( ADS_PROPERTY_UPDATE, "$attrib", ("$strValue 1", "$strValue 2", ... , "$strValue n") )' + @crlf $strHTML = $strHTML + '$$objItem.SetInfo()' + @crlf endif Next $strWriteCodeMV = $strHTML + @crlf EndFunction
;************************************************************************** ; These functions write script code to the code window for the Read ; an $object task. Each function varies based on the selected class. ; The function name describes the class it supports. ;************************************************************************** Function UserAttribsToRead $strHTML = ""
;All attributes on the General Properties Page $arrSVStringAttribsGP = "name", "givenName","initials","sn","displayName","description","physicalDeliveryOfficeName","telephoneNumber","mail","wWWHomePage" $strHTML = $strHTML + strReadCodeSV("General",$arrSVStringAttribsGP) $arrMVStringAttribsGP = "otherTelephone", "url" $strHTML = $strHTML + strReadCodeMV("General",$arrMVStringAttribsGP) ;End General Properties Page ;All attributes on the Address Properties Page $arrSVStringAttribsAP = "streetAddress", "l", "st", "postalCode", "c" $strHTML = $strHTML + strReadCodeSV("Address",$arrSVStringAttribsAP)
$arrMVStringAttribsAP = "postOfficeBox","" $strHTML = $strHTML + strReadCodeMV("Address",$arrMVStringAttribsAP) ;End Address Properties Page
;Selected attributes on the Account Properties Page $arrSVStringAttribsAcP = "userPrincipalName", "dc", "sAMAccountName", "userWorkstations" $strHTML = $strHTML + strReadCodeSV("Account",$arrSVStringAttribsAcP) ;Read the bit flags in userAccountControl $arrUACConstants = "ADS_UF_SMARTCARD_REQUIRED", "ADS_UF_TRUSTED_FOR_DELEGATION", "ADS_UF_NOT_DELEGATED", "ADS_UF_USE_DES_KEY_ONLY","ADS_UF_DONT_REQUIRE_PREAUTH" $arrUACValues = "&40000", "&80000", "&100000", "&200000", "&400000" $strHTML = $strHTML + IntReadCode("Account","userAccountControl", $arrUACConstants,$arrUACValues) ;End read the bit flags in userAccountControl ;Read the IsAccountLocked property $strHTML = $strHTML + 'If $$objItem.IsAccountLocked = $true' + @crlf $strHTML = $strHTML + $vbTab + '? "ADS_UF_LOCKOUT is enabled"' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '? "ADS_UF_LOCKOUT is disabled"' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf + @crlf ;End read the IsAccountLocked property ;Read the AccountExpirationDate property $strHTML = $strHTML + 'If (@@error = -2147467259) OR ($$objItem.AccountExpirationDate = "1/1/1970")' + @crlf $strHTML = $strHTML + $vbTab + '? "no expiration date."' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '? "Account expires on: " + $$objItem.AccountExpirationDate' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf + @crlf ;End read the AccountExpirationDate property ;End Account Properties Page ;All attributes on the Profile Properties Page $arrSVStringAttribsPrP = "profilePath", "scriptPath", "homeDirectory", "homeDrive" $strHTML = $strHTML + strReadCodeSV("Profile",$arrSVStringAttribsPrP) ;End Profile Properties Page ;All attributes on the Telephones Properties Page $arrSVStringAttribsTele = "homePhone","pager", "mobile","facsimileTelephoneNumber","ipPhone", "info" $strHTML = $strHTML + strReadCodeSV("Telephone",$arrSVStringAttribsTele) $arrMVStringAttribsTele = "otherHomePhone","otherPager", "otherMobile","otherFacsimileTelephoneNumber","otherIpPhone" $strHTML = $strHTML + strReadCodeMV("Telephone",$arrMVStringAttribsTele) ;End Telephones Properties Page ;All attributes on the Organization Properties Page $arrSVStringAttribsOrg = "title","department", "company","manager" $strHTML = $strHTML + strReadCodeSV("Organization",$arrSVStringAttribsOrg) $arrMVStringAttribsOrg = "directReports","" $strHTML = $strHTML + strReadCodeMV("Organization",$arrMVStringAttribsOrg) ;End Organization Properties Page ;All settings on the Environment Properties Page $arrProperties = "TerminalServicesInitialProgram", "TerminalServicesWorkDirectory","ConnectClientDrivesAtLogon","ConnectClientPrintersAtLogon","DefaultToMainPrinter" $strHTML = $strHTML + ReadPropertiesSimple("Environment","ADSI Extension for Terminal Services",$arrProperties) ;End all settings on the Environment Properties Page ;All settings on the Sessions Properties Page $arrProperties = "MaxDisconnectionTime","MaxConnectionTime", "MaxIdleTime","BrokenConnectionAction","ReconnectionAction" $strHTML = $strHTML + ReadPropertiesSimple("Sessions","ADSI Extension for Terminal Services",$arrProperties) ;End all settings on the Sessions Properties Page ;All settings on the Remote Control Properties page $arrProperties = "EnableRemoteControl","" $strHTML = $strHTML + ReadPropertiesSimple("Remote Control","ADSI Extension for Terminal Services",$arrProperties) $strHTML = $strHTML + 'Select' + @crlf $strHTML = $strHTML + $vbTab + 'Case $$objItem.EnableRemoteControl=0' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Remote Control disabled"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'Case $$objItem.EnableRemoteControl=1' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Remote Control enabled"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "User permission required"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Interact with the session"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'Case $$objItem.EnableRemoteControl=2' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Remote Control enabled"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "User permission not required"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Interact with the session"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'Case $$objItem.EnableRemoteControl=3' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Remote Control enabled"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "User permission required"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "View the session"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'Case $$objItem.EnableRemoteControl=4' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Remote Control enabled"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "User permission not required"' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "View the session"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + 'EndSelect' + @crlf + @crlf ;End all settings on the Remote Control Properties Page ;All settings on the Terminal Services Profile Properties page $arrProperties = "TerminalServicesProfilePath", "TerminalServicesHomeDirectory","TerminalServicesHomeDrive", "AllowLogon" $strHTML = $strHTML + ReadPropertiesSimple("Terminal Services Profile","ADSI Extension for Terminal Services",$arrProperties) ;End all settings on the Terminal Services Profile Properties page ;The attribute on the COM+ Properties page $arrSVStringAttribsCOM = "msCOM-UserPartitionSetLink","" $strHTML = $strHTML + strReadCodeSV("COM+",$arrSVStringAttribsCOM) ;End the attribute on the COM+ Properties page ;All attributes on the Member-Of Properties Page $arrSVStringAttribsMO = "primaryGroupID","" $strHTML = $strHTML + strReadCodeSV("Member Of",$arrSVStringAttribsMO) $arrMVStringAttribsMO = "memberOf","" $strHTML = $strHTML + strReadCodeMV("Member Of",$arrMVStringAttribsMO) ;End all attributes on the Member-Of Properties Page ;Selected attributes on the $object Properties Page $arrSVStringAttribsObj = "whenCreated","whenChanged" $strHTML = $strHTML + strReadCodeSV("Object",$arrSVStringAttribsObj) ;Added this because canonicalName is an operational attribute $strHTML = $strHTML + '$$arrMVStringAttribsObj = "canonicalName",""' $strHTML = $strHTML + '$$objItem.GetInfoEx( $$arrMVStringAttribsObj, 0)' + @crlf $arrMVStringAttribsObj = "canonicalName","" $strHTML = $strHTML + strReadCodeMV("Object",$arrMVStringAttribsObj) ;End all attributes on the $object Properties Page ;Dial-in and Security pages skipped. ;A later version of the tool might include a script to read these Properties pages. $UserAttribsToRead = $strHTML EndFunction
Function ContactAttribsToRead $strHTML = ""
;All attributes on the General Properites Page $arrSVStringAttribsGP = "name", "givenName","initials","sn","displayName","description","physicalDeliveryOfficeName","telephoneNumber","mail","wWWHomePage" $strHTML = $strHTML + strReadCodeSV("General",$arrSVStringAttribsGP) $arrMVStringAttribsGP = "otherTelephone", "url" $strHTML = $strHTML + strReadCodeMV("General",$arrMVStringAttribsGP) ;End General Properties Page ;All attributes on the Address Properties Page $arrSVStringAttribsAP = "streetAddress", "l", "st", "postalCode", "c" $strHTML = $strHTML + strReadCodeSV("Address",$arrSVStringAttribsAP)
$arrMVStringAttribsAP = "postOfficeBox","" $strHTML = $strHTML + strReadCodeMV("Address",$arrMVStringAttribsAP) ;End Address Properties Page
;All attributes on the Telephones Properties Page $arrSVStringAttribsTele = "homePhone","pager", "mobile","facsimileTelephoneNumber","ipPhone", "info" $strHTML = $strHTML + strReadCodeSV("Telephone",$arrSVStringAttribsTele) $arrMVStringAttribsTele = "otherHomePhone","otherPager", "otherMobile","otherFacsimileTelephoneNumber","otherIpPhone" $strHTML = $strHTML + strReadCodeMV("Telephone",$arrMVStringAttribsTele) ;End Telephones Properties Page ;All attributes on the Organization Properties Page $arrSVStringAttribsOrg = "title","department", "company","manager" $strHTML = $strHTML + strReadCodeSV("Organization",$arrSVStringAttribsOrg) $arrMVStringAttribsOrg = "directReports","" $strHTML = $strHTML + strReadCodeMV("Organization",$arrMVStringAttribsOrg) ;End Organization Properties Page ;All attributes on the Member-Of Properties Page $arrMVStringAttribsMO = "memberOf","" $strHTML = $strHTML + strReadCodeMV("Member Of",$arrMVStringAttribsMO) ;End all attributes on the Member-Of Properties Page ;Selected attributes on the $object Properties Page $arrSVStringAttribsObj = "whenCreated","whenChanged" $strHTML = $strHTML + strReadCodeSV("Object",$arrSVStringAttribsObj) ;Added this because canonicalName is an operational attribute $strHTML = $strHTML + '$$objItem.GetInfoEx( ("canonicalName",""), 0)' + @crlf $arrMVStringAttribsObj = "canonicalName","" $strHTML = $strHTML + strReadCodeMV("Object",$arrMVStringAttribsObj) ;End all attributes on the $object Properties Page ;Security page skipped. ;A later version of the tool might include a script to read this Properties page. $ContactAttribsToRead = $strHTML EndFunction
Function GroupAttribsToRead $strHTML = ""
;All attributes on the General Properties Page $arrSVStringAttribsGP = "name","samAccountName","description", "mail" $strHTML = $strHTML + strReadCodeSV("General",$arrSVStringAttribsGP)
;For reading the bit flags in grouptype $arrGTConstants = "ADS_GROUP_TYPE_GLOBAL_GROUP", "ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP", "ADS_GROUP_TYPE_UNIVERSAL_GROUP","ADS_GROUP_TYPE_SECURITY_ENABLED" $arrGTValues = "&2","&4","&8","&80000000" $strHTML = $strHTML + IntReadCode("General","groupType", $arrGTConstants,$arrGTValues) $strHTML = $strHTML + 'Select'+ @crlf $strHTML = $strHTML + $vbTab + 'case $$intgroupType & $$objHash.Item["ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP"]' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Group Scope: Domain Local Group"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'case $$intGroupType & $$objHash.Item["ADS_GROUP_TYPE_GLOBAL_GROUP"]' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Group Scope: Global Group"' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'case $$intGroupType & $$objHash.Item["ADS_GROUP_TYPE_UNIVERSAL_GROUP"]' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Group Scope: Universal Group"' + @crlf $strHTML = $strHTML + 'endselect' + @crlf $strHTML = $strHTML + 'If $$intgroupType & $$objHash.Item["ADS_GROUP_TYPE_SECURITY_ENABLED"]' + @crlf $strHTML = $strHTML + $vbTab + '? "Group Type: Security"' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '? "Group Type: Distribution"' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf ;End for reading the bit flags in grouptype ;End General Properties Page ;All attributes on the Managed By page. Code checks to see if the ;first field has a value. If so, it binds to the dn of the $object (user) ;and gets the properties of the $object specified on the Managed By page. $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strReadCodeSV("Managed By",$arrSVStringAttribsMB) $strHTML = $strHTML + 'If $$strmanagedBy <> ""' + @crlf $strHTML = $strHTML + $vbTab + '$$objItem1 = GetObject("LDAP://$strManagedBy")' + @crlf $arrMBProperties = "physicalDeliveryOfficeName","streetAddress", "l","c","telephoneNumber","facsimileTelephoneNumber" For Each $prop in $arrMBProperties if $prop $strHTML = $strHTML + $vbTab + '? "$prop : " + $$objItem1.' + $prop + @crlf endif Next $strHTML = $strHTML + 'EndIf' + @crlf + @crlf ;End all attributes on the Managed By page ;All attributes on the Member Properties Page $arrMVStringAttribsMO = "member","" $strHTML = $strHTML + strReadCodeMV("Member",$arrMVStringAttribsMO) ;End all attributes on the Member-Of Properties Page ;All attributes on the Member-Of Properties Page $arrMVStringAttribsMO = "memberOf","" $strHTML = $strHTML + strReadCodeMV("Member Of",$arrMVStringAttribsMO) ;End all attributes on the Member-Of Properties Page ;All attributes on the Managed By page ;Code checks to see if the ;first field has a value. If so, it binds to the dn of ;the $object (user or group) and gets the properties of the $object ;specified on the Managed By page. $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strReadCodeSV("Managed By",$arrSVStringAttribsMB) $strHTML = $strHTML + 'If $$strmanagedBy <> ""' + @crlf $strHTML = $strHTML + $vbTab + '$$objItem1 = GetObject("LDAP://$strManagedBy")' + @crlf $arrMBProperties = "physicalDeliveryOfficeName","streetAddress", "l","c","telephoneNumber","facsimileTelephoneNumber" For Each $prop in $arrMBProperties if $prop $strHTML = $strHTML + $vbTab + '? "$prop : " + $$objItem1.' + $prop + @crlf endif Next $strHTML = $strHTML + 'EndIf' + @crlf + @crlf ;End all attributes on the Managed By page $GroupAttribsToRead = $strHTML EndFunction
Function OUAttribsToRead $strHTML = ""
;All attributes on the General Properties Page $arrSVStringAttribsGP = "name", "description", "streetAddress", "postOfficeBox","l","st","postalCode","c" $strHTML = $strHTML + strReadCodeSV("General",$arrSVStringAttribsGP) ;End General Properties Page ;All attributes on the Managed By page ;Code checks to see if the first field has a value. If so, it binds to the dn of ;the $object (user or group) and gets the properties of the $object specified on the ;Managed By page. $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strReadCodeSV("Managed By",$arrSVStringAttribsMB) $strHTML = $strHTML + 'If $strmanagedBy <> ""' + @crlf $strHTML = $strHTML + $vbTab+'$$objItem1 = GetObject("LDAP://$strManagedBy")' + @crlf $arrMBProperties = "physicalDeliveryOfficeName","streetAddress", "l","c","telephoneNumber","facsimileTelephoneNumber" For Each $prop in $arrMBProperties if $prop $strHTML = $strHTML + $vbTab + '? "$prop : " + $$objItem1.$prop' + @crlf endif Next $strHTML = $strHTML + "EndIf" + @crlf + @crlf ;End all attributes on the Managed By page ;Selected attributes on the $object Properties Page $arrSVStringAttribsObj = "whenCreated","whenChanged" $strHTML = $strHTML + strReadCodeSV("Object",$arrSVStringAttribsObj) ;Added this because canonicalName is an operational attribute $strHTML = $strHTML + 'objItem.GetInfoEx( ("canonicalName",""), 0)' + @crlf $arrMVStringAttribsObj = "canonicalName","" $strHTML = $strHTML + strReadCodeMV("Object",$arrMVStringAttribsObj) ;End all attributes on the $object Properties Page ;Selected attributes on the Group Policy Properties Page $arrSVStringAttribsGP = "gPLink","gPOptions" $strHTML = $strHTML + strReadCodeSV("Group Policy",$arrSVStringAttribsGP) $strHTML = $strHTML + 'Select' + @crlf $strHTML = $strHTML + $vbTab + 'case $strgPOptions = 1' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Policy inheritance is blocked."' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'case $strgPOptions = 0' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Policies are inherited."' + @crlf $strHTML = $strHTML + @crlf $strHTML = $strHTML + $vbTab + 'case 1' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + '? "Policies are unknown."' + @crlf $strHTML = $strHTML + 'EndSelect' + @crlf + @crlf ;EndSelected attributes on the Group Policy Properties Page $OUAttribsToRead = $strHTML EndFunction
Function ComputerAttribsToRead $strHTML = ""
;All attributes on the General Properties Page $arrSVStringAttribsGP = "name","dnsHostName","description" $strHTML = $strHTML + strReadCodeSV("General",$arrSVStringAttribsGP) ;End General Properties Page ;For reading the bit flags in userAccountControl $arrUACConstants = "ADS_UF_TRUSTED_FOR_DELEGATION","ADS_UF_WORKSTATION_TRUST_ACCOUNT","ADS_UF_SERVER_TRUST_ACCOUNT" $arrUACValues = "&80000","&1000","&2000" $strHTML = $strHTML + IntReadCode("General","userAccountControl", $arrUACConstants,$arrUACValues) $strHTML = $strHTML + 'If $$intuserAccountControl && $$objHash.Item["ADS_UF_TRUSTED_FOR_DELEGATION"]' + @crlf $strHTML = $strHTML + $vbTab + '? "Trust computer for delegation"' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '? Do not trust the computer for delegation"' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf $strHTML = $strHTML + 'If $$intuserAccountControl && $$objHash.Item["ADS_UF_SERVER_TRUST_ACCOUNT"]' + @crlf $strHTML = $strHTML + $vbTab + '? Role: Domain Controller"' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '? Role: Workstation or Server"' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf ;End for reading the bit flags in userAccountControl ;All attributes on the Operating System Properties Page $arrSVStringAttribsGP = "operatingSystem","operatingSystemVersion", "operatingSystemServicePack" $strHTML = $strHTML + strReadCodeSV("Operating System",$arrSVStringAttribsGP) ;End Operating System Properties Page ;All attributes on the Member-Of Properties Page $arrSVStringAttribsMO = "primaryGroupID","" $strHTML = $strHTML + strReadCodeSV("Member Of",$arrSVStringAttribsMO) $arrMVStringAttribsMO = "memberOf","" $strHTML = $strHTML + strReadCodeMV("Member Of",$arrMVStringAttribsMO) ;End all attributes on the Member-Of Properties Page ;All attributes on the Location Properties Page $arrSVStringAttribsMO = "location","" $strHTML = $strHTML + strReadCodeSV("Location",$arrSVStringAttribsMO) ;End all attributes on the Location Properties Page ;All attributes on the Managed By page. The code checks to see if the ;first field has a value. If so, it binds to the dn of the $object (user) ;and gets the properties of the $object specified on the Managed By page. $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strReadCodeSV("Managed By",$arrSVStringAttribsMB) $strHTML = $strHTML + 'If $strmanagedBy <> ""' + @crlf $strHTML = $strHTML + $vbTab + '$$objItem1 = GetObject("LDAP://$strManagedBy")' + @crlf $arrMBProperties = "physicalDeliveryOfficeName","streetAddress", "l","c","telephoneNumber","facsimileTelephoneNumber" For Each $prop in $arrMBProperties if $prop $strHTML = $strHTML + $vbTab + '? "$prop : " + $$objItem1.$prop' + @crlf endif Next $strHTML = $strHTML + 'EndIf' + @crlf + @crlf ;End all attributes on the Managed By page
$ComputerAttribsToRead = $strHTML ;Dial-in page skipped. ;A later version of the tool might include a script to read this Properties page. debug off EndFunction
;************************************************************************** ; These functions write script code to the code window for the Write ; an $object task. Each function varies based on the selected class. ; The function name describes the class it supports. ;************************************************************************** Function UserAttribsToWrite $strHTML = ""
;Attributes on the General Properties Page $arrSVStringAttribsGP = "givenName","initials", "sn","displayName","description","physicalDeliveryOfficeName", "telephoneNumber","mail","wWWHomePage" $strHTML = $strHTML + strWriteCodeSV("General",$arrSVStringAttribsGP,"VALUE")
$arrMVStringAttribsGP = "otherTelephone", "url" $strHTML = $strHTML + strWriteCodeMV("General",$arrMVStringAttribsGP,"VALUE") ;End General Properties Page ;Attributes on the Address Properties Page $arrSVStringAttribsAP = "streetAddress", "l", "st","postalCode" $strHTML = $strHTML + strWriteCodeSV("Address",$arrSVStringAttribsAP,"VALUE") $arrSVStringAttribsAP = "c","" $strHTML = $strHTML + strWriteCodeSV("Address",$arrSVStringAttribsAP,"COUNTRY CODE VALUE")
$arrMVStringAttribsAP = "postOfficeBox","" $strHTML = $strHTML + strWriteCodeMV("Address",$arrMVStringAttribsAP,"VALUE") ;End Address Properties Page ;Attributes on the Profile Properties Page $arrSVStringAttribsPrP = "profilePath", "scriptPath", "homeDirectory" $strHTML = $strHTML + strWriteCodeSV("Profile",$arrSVStringAttribsPrP,"VALUE") $arrSVStringAttribsAP = "homeDrive","" $strHTML = $strHTML + strWriteCodeSV("Profile",$arrSVStringAttribsAP,"DRIVE LETTER VALUE (no colon)") ;End Profile Properties Page ;Attributes on the Telephones Properties Page $arrSVStringAttribsTele = "homePhone","pager","mobile","facsimileTelephoneNumber","ipPhone", "info" $strHTML = $strHTML + strWriteCodeSV("Telephone",$arrSVStringAttribsTele,"VALUE") $arrMVStringAttribsTele = "otherHomePhone","otherPager", "otherMobile","otherFacsimileTelephoneNumber","otherIpPhone" $strHTML = $strHTML + strWriteCodeMV("Telephone",$arrMVStringAttribsTele,"VALUE") ;End Telephones Properties Page ;Attributes on the Organization Properties Page $arrSVStringAttribsOrg = "title","department", "company" $strHTML = $strHTML + strWriteCodeSV("Organization",$arrSVStringAttribsOrg,"VALUE") $arrSVStringAttribsOrg = "manager","" $strHTML = $strHTML + strWriteCodeSV("Organization",$arrSVStringAttribsOrg,"DISTINGUISHED NAME VALUE") ;End attributes on the Organization Properties Page $UserAttribsToWrite = $strHTML ;Account, Terminal Services (Remote control, Terminal Services Profile, ;Environment, and Sessions) COM+, Dial-in and Security ;Properties pages skipped. A later version of the tool might include ;a script to write some or all these Properties pages. ;The Member Of properties page contains the memberOf backlink attribute. ;Modify the member property of a group to modify the contents ;of the memberOf attribute EndFunction
Function ContactAttribsToWrite $strHTML = ""
;Attributes on the General Properties Page $arrSVStringAttribsGP = "givenName","initials","sn","displayName","description","physicalDeliveryOfficeName","telephoneNumber","mail","wWWHomePage" $strHTML = $strHTML + strWriteCodeSV("General",$arrSVStringAttribsGP,"VALUE")
$arrMVStringAttribsGP = "otherTelephone", "url" $strHTML = $strHTML + strWriteCodeMV("General",$arrMVStringAttribsGP,"VALUE") ;End General Properties Page ;Attributes on the Address Properties Page $arrSVStringAttribsAP = "streetAddress", "l", "st", "postalCode" $strHTML = $strHTML + strWriteCodeSV("Address",$arrSVStringAttribsAP,"VALUE") $arrSVStringAttribsAP = "c","" $strHTML = $strHTML + strWriteCodeSV("Address",$arrSVStringAttribsAP,"COUNTRY CODE VALUE")
$arrMVStringAttribsAP = "postOfficeBox","" $strHTML = $strHTML + strWriteCodeMV("Address",$arrMVStringAttribsAP,"VALUE") ;End Address Properties Page ;Attributes on the Telephones Properties Page $arrSVStringAttribsTele = "homePhone","pager","mobile","facsimileTelephoneNumber","ipPhone", "info" $strHTML = $strHTML + strWriteCodeSV("Telephone",$arrSVStringAttribsTele,"VALUE") $arrMVStringAttribsTele = "otherHomePhone","otherPager","otherMobile","otherFacsimileTelephoneNumber","otherIpPhone" $strHTML = $strHTML + strWriteCodeMV("Telephone",$arrMVStringAttribsTele,"VALUE") ;End Telephones Properties Page ;Attributes on the Organization Properties Page $arrSVStringAttribsOrg = "title","department","company" $strHTML = $strHTML + strWriteCodeSV("Organization",$arrSVStringAttribsOrg,"VALUE") $arrSVStringAttribsOrg = "manager","" $strHTML = $strHTML + strWriteCodeSV("Organization",$arrSVStringAttribsOrg,"DISTINGUISHED NAME VALUE") ;End attributes on the Organization Properties Page
$ContactAttribsToWrite = $strHTML ;The Member Of properties page contains the memberOf backlink attribute. ;Modify the member property of a group to modify the contents ;of the memberOf attribute EndFunction
Function GroupAttribsToWrite $strHTML = ""
;Selected attributes on the General Properties Page $arrSVStringAttribsGP = "samAccountName","description","mail" $strHTML = $strHTML + strWriteCodeSV("General",$arrSVStringAttribsGP,"VALUE") ;End attributes on the General Properties Page ;Attributes on the Member Properties Page $arrMVStringAttribsMO = "member","" $strHTML = $strHTML + strWriteCodeMV("Member",$arrMVStringAttribsMO,"DISTINGUISHED NAME VALUE") ;End all attributes on the Member-Of Properties Page ;Attributes on the Managed By Properties Page $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strWriteCodeSV("Managed By",$arrSVStringAttribsMB,"DISTINGUISHED NAME VALUE") ;End attributes on the Managed By Properties Page $GroupAttribsToWrite = $strHTML ;The Member Of properties page contains the memberOf backlink attribute. ;Modify the member property of a group to modify the contents ;of the memberOf attribute EndFunction
Function OUAttribsToWrite $strHTML = ""
;Selected attributes on the General Properties Page $arrSVStringAttribsGP = "description","street", "postOfficeBox","l","st","postalCode" $strHTML = $strHTML + strWriteCodeSV("General",$arrSVStringAttribsGP,"VALUE") ;End General Properties Page $arrSVStringAttribsAP = "c","" $strHTML = $strHTML + strWriteCodeSV("Address",$arrSVStringAttribsAP,"COUNTRY CODE VALUE") ;Attributes on the Managed By Properties Page $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strWriteCodeSV("Managed By",$arrSVStringAttribsMB,"DISTINGUISHED NAME VALUE") ;End attributes on the Managed By Properties Page $OUAttribsToWrite = $strHTML ;COM+, and Group Policy Properties pages skipped. ;A later version of the tool might include ;a script to write some or all these Properties pages. EndFunction
Function ComputerAttribsToWrite $strHTML = ""
;Selected attributes on the General Properties Page $arrSVStringAttribsGP = "description","" $strHTML = $strHTML + strWriteCodeSV("General",$arrSVStringAttribsGP,"VALUE") ;End General Properties Page ;All attributes on the Location Properties Page $arrSVStringAttribsMO = "location","" $strHTML = $strHTML + strWriteCodeSV("Location",$arrSVStringAttribsMO,"VALUE") ;End all attributes on the Location Properties Page ;Attributes on the Managed By Properties Page $arrSVStringAttribsMB = "managedBy","" $strHTML = $strHTML + strWriteCodeSV("Managed By",$arrSVStringAttribsMB,"DISTINGUISHED NAME VALUE") ;End attributes on the Managed By Properties Page $ComputerAttribsToWrite = $strHTML ;The Operating System properties page contains attributes that are written when ;a computer becomes a member of the domain. ;The Member Of properties page contains the memberOf backlink attribute. ;Modify the member property of a group to modify the contents ;of the memberOf attribute. ;Dial-in page skipped. A later version of the tool might include ;a script to read this Properties page. EndFunction
;************************************************************************** ; These functions manipulate the script code that appears in the code ; window. Function details appear above each function. ;**************************************************************************
;Reformat the class name so that the first character of the class name is uppercase. ;This does not have an impact on the script's ability to run properly. Function ReformatObjName $strChar1 = UCase(Left($classesPulldown.Text,1)) $strRemaining = LCase(substr($classesPulldown.Text,2,len($classesPulldown.Text))) $ReformatObjName = "obj" + $strChar1 + $strRemaining EndFunction
Function FormatKixObjName($objname) do $i = instr( $objname,"-" ) if $i=0 $FormatKixObjName = $objname return endif if $i>1 $objname = left($objname,$i-1) + "_" + substr($objname,$i+1,len($objname)) else $objname = "_" + substr($objname,$i+1,len($objname)) endif until $false endfunction
;Determine whether the naming attribute for a method should be ou or cn Function NamingAttribute If $classesPulldown.Text = "organizationalUnit" $NamingAttribute = "ou" Else $NamingAttribute = "cn" EndIf EndFunction
;Size the code window and write some header script code based on the selected task. Function PreAmble($intCols,$intRows) $strHTML = "" $arrConstantesEnum = "$$ADS_GROUP_TYPE_GLOBAL_GROUP = &2", "$$ADS_GROUP_TYPE_LOCAL_GROUP = &4", "$$ADS_GROUP_TYPE_UNIVERSAL_GROUP = &8", "$$ADS_GROUP_TYPE_SECURITY_ENABLED = &80000000", "", "$$ADS_PROPERTY_CLEAR = 1", "$$ADS_PROPERTY_UPDATE = 2", "$$ADS_PROPERTY_APPEND = 3", "$$ADS_PROPERTY_DELETE = 4" $strHTML = $strHTML + ';-- constantes definition --' + @crlf For Each $constant In $arrConstantesEnum $strHTML = $strHTML + $constant + @crlf Next
$strHTML = $strHTML + @crlf $strHTML = $strHTML + ';-- variables definition --' + @crlf $strHTML = $strHTML + '$$strContainer = ""' + @crlf $strHTML = $strHTML + '$$strSearchName = "EzAd' + UCase(Left($classesPulldown.Text,1)) + substr($classesPulldown.Text,2,len($classesPulldown.Text)) + '"' + @crlf
$PreAmble = $strHTML + @crlf EndFunction
;Generate the binding $string text for the script Function BindString $strHTML = "" If ($TaskSelectPulldown.Text = "Create an object") OR ($TaskSelectPulldown.Text = "Delete an $object") $strObj = "objContainer" $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + ';* Connect to a container *' + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + '$$objRootDSE = GetObject("LDAP://rootDSE")' + @crlf $strHTML = $strHTML + 'If $strContainer = ""' + @crlf $strHTML = $strHTML + $vbTab + '$$$strobj = GetObject("LDAP://cn=$strSearchName," + $$objRootDSE.Get("defaultNamingContext"))' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '$$$strObj = GetObject("LDAP://cn=$$strSearchName,$strContainer," + $$objRootDSE.Get("defaultNamingContext"))' + @crlf $strHTML = $strHTML + 'EndIf' + @crlf
;The remarked section adds error testing to determine if the attempted ;connection to a domain failed. ;$strHTML = $strHTML + "If @@error = 424 " + @crlf ;$strHTML = $strHTML + " ? You must run the script from an Active Directory enabled client." + @crlf ;$strHTML = $strHTML + " Quit 1" + @crlf ;$strHTML = $strHTML + "EndIf" + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + ';* End connect to a container *' + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf + @crlf Else $strObj = "objItem" $strNamingAttribute = NamingAttribute() $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + ';* Connect to an object *' + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + '$$objRootDSE = GetObject("LDAP://rootDSE")' + @crlf $strHTML = $strHTML + 'If $strContainer = ""' + @crlf If $classesPulldown.Text = "organizationalUnit" $strHTML = $strHTML + $vbTab + '$$arrNameExceptions = ("Users","Computers","Builtin","System","ForeignSecurityPrincipals","LostAndFound")' + @crlf $strHTML = $strHTML + $vbTab + 'For Each $$name in $$arrNameExceptions' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + 'If lcase($$strSearchName) = lcase($$name)' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + $vbTab + '$$strNameAttrib = "cn="' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + $vbTab + 'Exit For' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + 'Else' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + $vbTab + '$$strNameAttrib = "ou="' + @crlf $strHTML = $strHTML + $vbTab + $vbTab + 'EndIf' + @crlf $strHTML = $strHTML + $vbTab + 'Next' + @crlf $strHTML = $strHTML + $vbTab + '$$$strObj = GetObject("LDAP://$strNameAttrib=$strSearchName,"+$$objRootDSE.Get("defaultNamingContext"))' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '$$$strObj = GetObject("LDAP://$strNamingAttribute=$strSearchName,$strContainer,$"+$objRootDSE.Get("defaultNamingContext"))' + @crlf Else $strHTML = $strHTML + $vbTab + '$$$strObj = GetObject("LDAP://cn=$strSearchName,"+$$objRootDSE.Get("defaultNamingContext"))' + @crlf $strHTML = $strHTML + 'Else' + @crlf $strHTML = $strHTML + $vbTab + '$$$strObj = GetObject("LDAP://$strNamingAttribute=$$strSearchName,$strContainer,"+$$objRootDSE.Get("defaultNamingContext"))' + @crlf EndIf $strHTML = $strHTML + 'EndIf' + @crlf ;The remarked section adds error testing to determine if the attempted ;connection to a domain failed. ;$strHTML = $strHTML + "If @@error = 424 " + @crlf ;$strHTML = $strHTML + " ? You must run the script from an Active Directory enabled client." + @crlf ;$strHTML = $strHTML + " Quit 1" + @crlf ;$strHTML = $strHTML + "EndIf" + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf $strHTML = $strHTML + ';* End connect to an object *' + @crlf $strHTML = $strHTML + ';***********************************************' + @crlf + @crlf EndIf $BindString = $strHTML EndFunction
;************************************************************************** ; These two routines generate the text that appears in the two modal dialog ; boxes. These dialog boxes appear when the Running This Script or ; Script Notes buttons are pressed. ;************************************************************************** function DoViewHelp( $title, $height, $width, $message ) if $message="" return endif
dim $ie,$doc,$f,$t
$ie = createobject("internetexplorer.application") $ie.width = $width $ie.height = $height $ie.addressbar=0 $ie.menubar=0 $ie.toolbar=0 $ie.statusbar=0 $ie.navigate("about:blank") $doc = $ie.document $doc.write("<html><head><title>$title</title></head>"+join(split($message,@crlf),"<br>")+"</html>") $ie.visible=1
while $ie.visible sleep 0.25 loop $frmMain.Refresh $frmMain.SetFocus
$ie = nothing endfunction
function RunDialog() $intwidth = 800 $title = "Before Running The " + $TaskSelectPulldown.Text + " - " + UCase(Left($classesPulldown.Text,1)) + substr($classesPulldown.Text,2,len($classesPulldown.Text)) + " Script"
$strHTML = "" $strHTML = $strHTML + "<head>" $strHTML = $strHTML + "<style>" $strHTML = $strHTML + "BODY{background-color: beige;font-family: arial;font-size:10pt;margin-left:10px;}" $strHTML = $strHTML + "div.head{font-size:12pt;font-weight:bold;}" $strHTML = $strHTML + "div.code{font-size:10pt;font-family:courier;margin-left:10px}" $strHTML = $strHTML + "UL{margin-top:5px;margin-bottom:5px;}" $strHTML = $strHTML + "</style>" $strHTML = $strHTML + "</head>" $strHTML = $strHTML + "<body>" $strAddlNotes = "" Select Case "Create an object" $arrAltText = "create", lcase($TaskSelectPulldown.Text), " to create" Case "Write an object" $arrAltText = "write", lcase($TaskSelectPulldown.Text), " whose attributes you will assign" $strAddlNotes = "<div class = head>Attribute Values</div>" + "<UL><li><i>VALUE</i> or <i>VALUEn</i> - $string values" + "<li><i>COUNTRY CODE VALUE</i> - This value is a two-digit country code. For a " + "list of country codes, see <A href=http://www.iso.org>The ISO Web site</A>" + "<li><i>DRIVE LETTER VALUE</i> - This value is a drive letter, " + "typically a value between F and Z. Do not specify a colon following the letter." + "<li><i>DISTINGUISHED NAME VALUE</i> - This value is the DN of an $object." + @crlf + "<b>Examples</b>" + @crlf + "The MyerKen user account in the Management OU of the NA.fabrikam.com domain:" + "<div class=code>cn=myerken,ou=management,dc=na,dc=fabrikam,dc=com</div>" + "The Atl-Users group in the Users container of the contoso.com domain:" + "<div class=code>cn=atl-users,cn=users,dc=contoso,dc=com</div>" + "</UL>" Case "Read an object" $arrAltText = "read", lcase($TaskSelectPulldown.Text), " whose attributes you will read" Case "Delete an object" $arrAltText = "dele
_________________________
Christophe
|
|
Top
|
|
|
|
#101184 - 2003-05-23 07:15 PM
Re: Microsoft releases ADSI Scriptomatic
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
When creating a query to look for say my computer in the script, we see errors with line 50 and then 53
code:
If $intuserAccountControl && $objHash.Item["ADS_UF_TRUSTED_FOR_DELEGATION"] ... ? Do not trust the computer for delegation" ...
Changed the code around to -
code:
If $intuserAccountControl + $objHash.Item["ADS_UF_TRUSTED_FOR_DELEGATION"] ... ? "Do not trust the computer for delegation" ...
Seems to work ok, but not really showing any info.
Added in - quote:
$strContainer = "" $strSearchName = "COMPUTERNAME"
Save does not appear to work.
Thanks,
Kent [ 23. May 2003, 19:15: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#101186 - 2003-05-27 04:32 AM
Re: Microsoft releases ADSI Scriptomatic
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
I could be wrong (I'm not at work on an AD to test it right now), but this line does not look like it would function correctly.
quote: $strHTML = $strHTML + '$$strSearchName = "EzAd' + UCase(Left($classesPulldown.Text,1)) + substr($classesPulldown.Text,2,len($classesPulldown.Text)) + '"' + @crlf
It appears as though it will take the computer name and class and put it into a single variable. Thus an LDAP call would fail as you are attempting to add invalid data to the var.
i.e. EzAd would be added to Computer class as one example.
Thus "EzAdComputer" would not return valid data.
Maybe I'm looking at it wrong though. If I am correct then why not use @WKSTA
I'll try to test it out at work though to make sure.
|
|
Top
|
|
|
|
#101188 - 2003-05-28 03:46 AM
Re: Microsoft releases ADSI Scriptomatic
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
I posted an updated KiXform version of this along with some other minor updates in the Scripts forum.
ADSIKiXScriptomatic Learning Tool
Thanks go to Ch Melin for the original work and Shawn for some enhancement ideas.
Edited by NTDOC (2005-06-10 10:08 AM)
|
|
Top
|
|
|
|
#101189 - 2003-05-28 08:38 AM
Re: Microsoft releases ADSI Scriptomatic
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 657 anonymous users online.
|
|
|