Map a network drive via a security group that checks for that drive first
I need to be able to map a network drive to the first available drive that also checks before it maps that drive to see if the same path already exists. Below is what I have

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network"

)

strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
    strGroupPath = "LDAP://" & strGroup
    Set objGroup = GetObject(strGroupPath)
    strGroupName = objGroup.CN

    Select Case strGroupName
        Case "Security group name"
            objNetwork.MapNetworkDrive AvailableDriveLetter,"SharePath "

        Case "Security Group name"
            objNetwork.MapNetworkDrive AvailableDriveLetter, "Share Path"
    End Select
Next
'-------------------------------------------------

Function AvailableDriveLetter
   With CreateObject("Scripting.FileSystemObject")
      For i = Asc("D") To Asc("Z")
         If Not .DriveExists(Chr(i)) Then
            AvailableDriveLetter = Chr(i) & ":"
            Exit For
         End If
      Next
   End With
End Function

Any help is appreciated.

August 31st, 2015 12:34am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics