Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login script with domain user Credential

Status
Not open for further replies.

neutec

Technical User
Joined
Apr 26, 2003
Messages
343
Hello,
is it poissible to use a varible the can use Windows credentials (SSPI) in a vbscript? I have a login script that maps drives to users at login. Remote user login via VPN and need to pass the Windows Token to login to share domain resoure. I was wondering if this can be integrated into the script below.
Code:
Dim fs, d, dc, WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set dc = fs.Drives
If fs.DriveExists("R") Then
    'Drive R has been previously assigned and still is currently assigned.
    If dc("R").ShareName = "\\Dc1\American Contractor Data" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive S has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "S:", "\\Dc1\CMCSYNC"
End If
If fs.DriveExists("L") Then
    'Drive L has been previously assigned and still is currently assigned.
    If dc("L").ShareName = "\\Dc1\Letterlog" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive L has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "L:", "\\Dc1\Letterlog"
End If 
If fs.DriveExists("M") Then
    'Drive M has been previously assigned and still is currently assigned.
    If dc("M").ShareName = "\\Dc1\Company" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive M has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "M:", "\\Dc1\Company"
End If 
If fs.DriveExists("N") Then
    'Drive N has been previously assigned and still is currently assigned.
    If dc("N").ShareName = "\\Dc1\Userdata" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive N has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "N:", "\\Dc1\Userdata"
End If 
If fs.DriveExists("O") Then
    'Drive O has been previously assigned and still is currently assigned.
    If dc("O").ShareName = "\\Dc1\AmericanContractor" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive O has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "O:", "\\Dc1\AmericanContractor"
End If 
If fs.DriveExists("T") Then
    'Drive T has been previously assigned and still is currently assigned.
    If dc("T").ShareName = "\\Dc1\Public" Then
        'The sharename is already assigned to the drive letter
    Else
        'The drive letter is already taken up, but not with the expected sharename.
    End If
Else
    'Drive T has not been assigned, so we will assign it.
    WshNetwork.MapNetworkDrive "T:", "\\Dc1\Public"
End If
 
I not clear about what you're asking. Rephrase or give an example.

Side Note: You're login script is quite redundant - it's executing the same code 6 times. Perhaps, for readibilty sake, you should functionalize the code and just call it 6 times.

Ex:
Code:
function mapDrive(strDrive, strShare)
    Dim fs, d, dc, WshNetwork
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives

    If fs.DriveExists(strDrive) Then
        'Drive R has been previously assigned and still is currently assigned.
        If dc(strDrive).ShareName = strShare Then
            'The sharename is already assigned to the drive letter
        Else
            'The drive letter is already taken up, but not with the expected sharename.
        End If
    Else
        'Drive S has not been assigned, so we will assign it.
        WshNetwork.MapNetworkDrive strDrive & ":", strShare
    End If
end function

mapDrive "S", "\\Dc1\CMCSYNC"
mapDrive "L", "\\Dc1\Letterlog"
mapDrive "M", "\\Dc1\Company"
mapDrive "N", "\\Dc1\Userdata"
mapDrive "O", "\\Dc1\AmericanContractor"
mapDrive "T", "\\Dc1\Public"

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top