Skip to Main Content
Active Directory, 3rd Edition
book

Active Directory, 3rd Edition

by Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
January 2006
Beginner content levelBeginner
832 pages
27h 52m
English
O'Reilly Media, Inc.
Content preview from Active Directory, 3rd Edition

Creating and Manipulating Shares with ADSI

The following code shows how easily you can create shares with ADSI:

    Dim objComputer, objFileShare

    Set objComputer = GetObject("WinNT://mycomputer/LanmanServer 
")

    Set objFileShare = objComputer.Create("FileShare", "MyNewShare")
    objFileShare.Path = "c:\mydirectory"
    objFileShare.Description = "My new Share"
    objFileShare.MaxUserCount = 8
    objFileShare.SetInfo

After we declare the objComputer and objFileShare variables, we bind to the LanmanServer object on the computer on which we want to create the shares. LanmanServer is the object name of the server service that runs on all Windows NT and later computers. We bind to this object because NT's predecessor was LAN Manager and is still present to a large extent in the Windows OS.

Next, we use the IADsContainer::Create method to create an object of class FileShare with the name MyNewShare and apply the IADsFileShare property methods to set the path, description, and maximum number of users. On an NT, Windows 2000, or Windows Server 2003 server, you can grant all users access to a share or limit access to as many users as you want. On a workstation, you can grant all users access to a share or limit access to between 1 and 10 users at a time. The latter restriction is due to the 10-connection limit that the OS imposes. The values that the IADsFileShare::MaxUserCount method accepts are -1 (which grants all users access), any numerical value between 1 and 10 on workstations, and, within reason, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory, 4th Edition

Active Directory, 4th Edition

Brian Desmond, Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
Active Directory, Second Edition

Active Directory, Second Edition

Robbie Allen, Alistair G. Lowe-Norris

Publisher Resources

ISBN: 0596101732Supplemental ContentErrata Page