Publishing Shared Folders in Active Directory

Microsoft® Windows® 2000 Scripting Guide

One problem with shared folders is that each shared folder is tied to an individual computer. To access the resources on a shared folder, users must know not only the name of the shared folder itself but also the name of the computer where that shared folder is located. In a large organization, this can make it difficult to find resources.

One way to overcome this problem is to publish shared folders in Active Directory. When a shared folder is published in Active Directory, users can search for such a folder using Network Neighborhood.

You can also search for shared folders using ADSI scripts or Active Directory Users and Computers. Regardless of the tool you use, you can search for these resources based not only on name but also on description or keyword.

Shared folders are published in Active Directory by creating an instance of the Volume class that represents the shared folder. Some of the key attributes of the Volume class are listed in Table 11.14.

Table 11.14 Volume Class Attributes

Attribute

Description

CN

Common name. Name of the object as displayed in Active Directory Users and Computers. (This is typically the same name as the share name.) For example:

FinanceShare

UNCName

UNC path of the shared folder. For example:

\\Server1\FinanceShare

Description

Description of the share and its contents.

Keywords

Array of descriptive terms that can be used in searching for specific shared folders.

ManagedBy

Indicates the user responsible for the share.

Folders can be published in Active Directory either by using Active Directory Users and Computers or by using a custom ADSI script. An ADSI script can also be used to enumerate all the shared folders on a computer and then publish each one in Active Directory.

Scripting Steps

Listing 11.38 contains a script that publishes a shared folder in Active Directory. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the organizational unit in Active Directory where the shared folder will be published.

  2. Use the Create method to create the shared folder object. The Create method is passed two parameters:

    • Volume - Indicates that the entity being created is a shared folder.

    • CN = FinanceShare - Specifies the name of the published folder.

  3. Use the Put method to specify the network path to the shared folder.

  4. Use the Put method to specify a description of the shared folder.

    This description is available to anyone who accesses the shared folder in Active Directory Users and Computers. However, this description is not available to anyone accessing the shared folder by using Network Neighborhood, nor is this the same description as the one set using the WMI Win32_Share class.

  5. Use the Put method to specify keywords that can be used when searching for this folder.

    The Keywords property is a multiple-attribute property; that is, it can accept more than one value. To assign multiple keywords to the folder, the keywords are passed as parameters using the Array method.

  6. Use the SetInfo method to apply the changes and publish the folder in Active Directory.

Listing 11.38 Publishing a Shared Folder in Active Directory

  
1
2
3
4
5
6
7
Set objComputer = GetObject _
 ("LDAP://OU=Finance, DC=fabrikam, DC=com")
Set objShare = objComputer.Create("volume", "CN=FinanceShare")
objShare.Put "uNCName", "\\atl-dc-02\FinanceShare"
objShare.Put "Description", "Public share for users in the Finance group."
objShare.Put "Keywords", Array("finance", "fiscal", "monetary")
objShare.SetInfo