ADSI and file shares 
Author Message
 ADSI and file shares

I've written a VB script to find and then delete a user's network file
share.  My script works fine as long as it finds a share while bound to the
LanmanServer object.  When the script has searched each share name but can't
find a match it always stops with the error: Object required 'objShare'.
This seems to be a problem with this lanmanserver object.  It does not
behave like a collection where it knows when it has looped through each of
it's elements.  In this case when my script has looped through each element
(my variable objShare) it bombs as if it is still looking for the next
objShare (as if it does not know that it has reached the end of the
collection )?

I've tried other methods for counting share elements and trying to get it to
exit the "for loop" when it reached the end, but it always gets an error
when it reaches the end of the shares.

Does anyone have any additional information about the lanmanserver object?
Thanks!

Sub DeleteShare (HomeServer, UserName)
    dim boolFoundIt, objShare, objLanMan
    set objLanMan = GetObject("WinNT://UWPN/" &HomeServer &"/lanmanserver")
    boolFoundIt = False
        For Each objShare In objLanMan
            If objShare.name = UserName & "$" then
                boolFoundIt = True
                Exit For
            Else
                boolFoundIt = False
            End If
        Next

      If boolFoundIt = False Then
           MsgBox "Can't find share for " & UserID
      Else                        ' boolFoundIt = True

           objLanMan.delete "fileshare" ,  UserName & "$"
      End If
End Sub



Sun, 29 Jun 2003 02:45:40 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Directory, share, Win2000, access rights, ADSI

2. Directories, sharing, Win2000, Access rights, ADSI

3. ADSI Object (Lets you enumerate users, servers, groups, shares, It's the business)

4. Creating a SHARE using ADSI

5. Creating a share on a Windows95 computer using ADSI

6. Share info Using Active Directory Services (ADSI)

7. ADSI Deleting Share ?

8. How can I set permission on a share using VB/ADSI

9. Using ADSI to list all shares on a computer

10. Sharing through ADSI

11. Shared network resources by ADSI

12. ADSI and Shares

 

 
Powered by phpBB® Forum Software