Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Acrobat

  • Print
  • + Share This
Like this article? We recommend

The following covers in detail what happens with each script and function. I will cover the two functions first and then explain how they are called in the originating script.

Enumerate the Groups: GroupArray()

KiXtart allows for the creation of user-defined functions, allowing your scripts to be made more modular. The following function creates an array of all groups (Active Directory or NT SAM) that a user is member of.

This is done by iterating through all groups in which a user takes part and building an array. The KiXtart, EnumGroup function provides this functionality.

The script creates a string variable called, "$strGrpLst". A "Do...Until" loop repeatedly calls the EnumGroup function, which returns a group name based on the numeric value contained in the variable "$i". The variable "$i" is incremented at each loop, and after it exceeds the number of groups a user is part of, the enumGroup() function will return a zero length string.

The variable "$strGrpLst" is then parsed into an Array using the Split() function. This array is then assigned to a variable that matches the function name, which causes the function to return the array to the calling script.

Map the Drives: GroupMap()

The group map function uses the information contained in the drivemapping.ini file to map drives based on the security group names that are now contained in the array created above.

The function receives two parameters, the full path and name of the .ini file (in this example, c:\kixwork\drivemapping.ini) and the name of a security group (retrieved from the above reference array).

A built-in KiXtart function, ReadProfileString(), searches the .ini file looking for a section that matches the current security group name and returns an array with the number of lines in a given section of the file.

If no matching section is found, the function completes without taking any action. If a section is located, however, the function loops through each line in the section.

The readprofilestring is called again, specifically referencing a line of data in the .ini file section located. As you can see, each line of data in the drivemapping.ini file contains the following information:

MapDrive1=v,\\servername\sharename

The readprofilestring function returns a string containing the drive letter and the server and share name desired for that drive mapping.

Once again, the split function is called to create an array with the drive letter and the server and sharename to be mapped.

The script then calls the KiXtart command "use" specifying the array element with the drive letter and the array element with the server and share name. The use command is the same as the NT net use command.

If the original call to ReadProfileString has returned multiple key values in the section of the .ini file, the script loops through and maps the next drive letter, share combination. For example, the [Domain Users] section in my drivemapping.ini file contains two keys. The [AGroup] and [BGroup] sections only contain one each.

Putting It All Together: DriveMap.kix

All the functions are referenced by running the drivemap.kix file. The first line calls the MyFunctions.kix file into memory. This makes the two user-defined functions available for the remainder of the script.

An array, $aryGroups, is then filled with all the SAM or Active Directory security groups for that user. A variable, $strIniFile, is set to include the path to our drivemappings.ini file.

Then a for...next loop is initiated that will take the script through each array element in $aryGroups. In this loop, the GroupMap function is called with the path to the drivemapping.ini file, and a value, the name of a group, from the array of security groups.

After all groups in the array have been evaluated for their entry in the drivemappings.ini file, the script ends.

  • + Share This
  • 🔖 Save To Your Account