How to Write a Script to Detect Problems with the Import File (311187)
The information in this article applies to:
- Microsoft Metadirectory Services 2.1
- Microsoft Metadirectory Services 2.2
- Microsoft Metadirectory Services 2.2 SP1
This article was previously published under Q311187 SUMMARY
A large number of connector space objects or metaverse objects can be made obsolete if connectivity is lost between the Cdir program and the connected directory. If you are using the provisioning agent (Together Administration management agent [TAMA]) to provision one or more other connected directories, the objects may be deleted from those folders if connectivity is lost. This article describes how to write a script to prevent metaverse objects from being made obsolete if connectivity is lost.
MORE INFORMATION
When you run a management agent in Full mode, Microsoft Metadirectory Services (MMS) assumes that the import file contains all of the objects that are discovered in the connected directory. When the management agent is not in Delta mode, MMS assumes that any object that is not present in the import file has been deleted from the connected directory. MMS assumes that the object will also be made obsolete from the metadirectory. If connectivity was lost while the file was being built during the management agent run, the file may be truncated and metaverse objects may be made obsolete by mistake. To prevent this behavior, you can write an executable code which renames the previous import file and checks the new import file against the previous file for size discrepancies. If the file does not meet the check, your code can delete the file and MMS does not make metaverse objects obsolete. You can write this executable code in any language (such as VBScript or Perl), so that the executable code can be called by the management agent control script.
For example, you can write a code that renames the existing import file from the previous run at the start of the current run, and then checks the size of the new import file against the previous file. If the new file is significantly smaller than the previous file, MMS either deletes or renames the import file and synchronization is stopped. If no import file is present or if the file exists but is zero bytes in size, MMS stops the synchronization process. When this behavior occurs, the following data is logged in the Zscript.log file:
19012-ERROR: can not open [import]
*****Reference of Error Code******
ERROR 19012: DS_RC_FILE_ERROR
To write this code, you must write two VBS scripts and call them from the management agent control script. Use the scripts that are described in the following sections as a sample only. Although, these scripts have been tested in a lab environment, you may have to use additional logic to adapt these scripts to satisfy the specific requirements of your current environment. Additionally, you may want to use these scripts to enhance the capability of the existing scripts. For example, you may want to add additional error checking to test for the existence of the import files before you run either script. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. How to Write the SaveFile.vbs File
To write a VBScript code to save the old import file before the new import file is written:
- Start a text editor such as Notepad.
- Copy the following code to Notepad (make sure to change the value of the import file paths to match your environment):
'***********************************************************
'Save the old Import file
'In this example the MA working directory is number 6
'***********************************************************
Dim oFS, wshshell
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
oFS.CopyFile "C:\zoomserv\data\Ds\00000006\import","C:\zoomserv\data\Ds\00000006\import.old"
Set wshshell = wscript.CreateObject("wscript.shell")
'Log event to application log
wshshell.LogEvent 0, "Renamed Import File"
'Clean up
Set oFS = Nothing
Set wshshell = Nothing
- Save the file as SaveFile.vbs.
How to Write the CheckSize.vbs File
To write a VBScript code to test the size of the new file in comparison to the old file, and then delete the new file if it is less than 95 percent of the size of the old file:
- Start a text editor such as Notepad.
- Copy the following code to Notepad (make sure to change the value of the import file paths to match your environment):
'***********************************************************
'Delete new Import file if size is < 95% of old Import file
'In this example, the MA working directory is number 6
'***********************************************************
'Declare variables
Dim oFS, oFile1, oFile2, oldsize, newsize, wshshell
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Set oFile1 = oFS.GetFile("C:\zoomserv\data\Ds\00000006\import")
Set oFile2 = oFS.GetFile("C:\zoomserv\data\Ds\00000006\import.old")
newsize = oFile1.Size
oldsize = oFile2.Size
'Compare size to old file size
If newsize < 0.95 * oldsize Then
oFS.DeleteFile "C:\zoomserv\data\Ds\00000006\import"
End If
Set wshshell = wscript.CreateObject("wscript.shell")
'Log event to application log
wshshell.LogEvent 1, "Import File Too Small, Deleted"
'Clean up
Set oFS = Nothing
Set oFile1 = Nothing
Set oFile2 = Nothing
Set wshshell = Nothing
- Save the file as CheckSize.vbs.
How to Make Changes to the MAScript.scr File to Incorporate the Other Scripts- Start the MMS Compass utility, and then locate the management agent for which you want to run the .vbs files that you created in the earlier sections.
- Click Design MA.
- Click the Control MA Operations tab.
- Click the MA Control Script tab.
- Locate the following line of code:
IF %zcDsPerformDiscovery% = TRUE THEN
IF %zcRequestFlash% = TRUE THEN
Flash Start of Users Discovery
ENDIF
echo**********************************************************
echo Start of Users Discovery
echo ******************************************************************
- Add the following code:
#Executing the Save script located in \zoomserv\bin directory.
Execute SaveFile.VBS
- Locate the following line of code:
echo ******************************************************************
echo Synchronizing Metadirectory Users
echo ******************************************************************
- Add the follow line of code after the echo statements and before the Importt.exe program is run:
#Executing the CheckSize script located in the \zoomserv\bin directory.
Execute CheckSize.VBS
Additionally, Microsoft recommends that you set a deletion limit on the management agent to a specific threshold:
- Click the management agent.
- On the Action menu, click Operate MA.
- Click the Operational Settings tab.
- Click the Limits tab.
- In the Abort the synchronization process if _ consecutive deletions are encountered box, change the value to 100 (or use another reasonable numeric value).
Modification Type: | Major | Last Reviewed: | 6/29/2005 |
---|
Keywords: | kbenv kbinfo KB311187 |
---|
|