• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

VBScript Logon Script

Hello,

I am having a little trouble with mapped drives and our logon script.  It appears to me that the portion of our logon script that maps the users' home directories is not working.  If I use AD to do this, I get the home drive, but users who connect remotely, do not.  I'm thinking I need to change my logon script or something.  If I take away the AD connection to the home folder and just use the logon script, no home drive, even though there is a routine in the logon script that is supposed to map the drive.  I've included the code from my logon script up to stuff that really doesn't pertain to this situation.  If we need more, let me know.

Thanks,
Cheese
Option Explicit
Dim objNetwork, objSysInfo, strUserDN
Dim objGroupList, objUser, objFSO
Dim strComputerDN, objComputer
Dim strHomeShare, strHomeDrive
Dim ComputerName
 
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
strComputerDN = objSysInfo.computerName
 
' Bind to the user and computer objects with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
Set objComputer = GetObject("LDAP://" & strComputerDN)
 
' Map user home directory.
strHomeShare = objUser.homeDirectory
If (strHomeShare <> "") Then
    strHomeDrive = objUser.homeDrive
    If (strHomeDrive = "") Then
        strHomeDrive = "H:"
    End If
    On Error Resume Next
    objNetwork.MapNetworkDrive strHomeDrive, strHomeShare
    If (Err.Number <> 0) Then
        On Error GoTo 0
        objNetwork.RemoveNetworkDrive strHomeDrive, True, True
        objNetwork.MapNetworkDrive strHomeDrive, strHomeShare
    End If
    On Error GoTo 0
End If

Open in new window

0
cheesebugah
Asked:
cheesebugah
  • 5
  • 4
1 Solution
 
Mark PavlakCommented:
I am confused.  If you are removing the Home Directory from the AD account then why are you trying to map it based on Information you are pulling from the homDrive atribute it will return an empty value that may be your problem.
0
 
cheesebugahAuthor Commented:
jfinner2,

We have an issue here on our network, when people who have been connected to the network, VPN into the network from afar, their H drive is not getting mapped through the VPN.  I was leaning toward using the login script instead of AD to map users' drives, thinking that might be the issue.  I was testing it on my machine.  I removed the H drive from my AD account and logged into the network, but did not get my H drive via the login script either.  So, I think there is something messed up with the login script.  Does that make it any clearer or have I confused you even more?

Thanks,
Cheese
0
 
Mark PavlakCommented:
I understand your delmia as I work in an enviroment in which I have a modest handful of users who VPN in from outher offices.  The most inherent issue you will have is that inorder for the H drive to map you must have network.  You dont get network untill VPN is established, as you well know.  Therefore anytype of "Login",Startup" script you may have will not work as they run prior to the establishment of the VPN.  If I may suggest.  By reading the script you already have, it basically queries AD frinds the user account and pulls the .HomeDrive attribute to get the drive letter and the .homeDirectory call will return the path of the homedrive.  THis being said when you blank out those fields in AD so it doesnt mapp the H drive then the script you have will do you no good as those attributes are empty.  What I suggest is.... Let AD handle the H drives, it is the best way in my opinion as it set perms and evrything thing else that is required of a tru Netowrk folder.  Use the script that you have for your VPN users, but not as a "Login" script as you have to establish the VPN before it will run properly.  Put the script in the all users folder\desktop  so that the users of the desktop can double click it mapping their H drive.  The are really two other options you can persue.  Write a script which launches the VPN goes to sleep waits for the network then runs the H drive mapping OR on a per user basis ( i would do this only IF you kepp you H drives statically in one place for the duration of the user account) Manuallly map the H drive and hit the check box for Reconnect at logon.  It will keep the mapping even though it wont be active unless you are on a VPN,  Hope this helps, if you need any scripts written/modified please let me know.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
cheesebugahAuthor Commented:
I just wanted to update this question.  We are working on the login script and am leaning toward manually mapping a user's H drive and unchecking the AD Home folder under the user's profile in AD.  It worked for me.

Thanks,
Cheese
0
 
Mark PavlakCommented:
You should uncheck the H drive mapping in their AD profile.  What will happen when they logon on a pc local to your network? No H drive?
0
 
cheesebugahAuthor Commented:
Each user has their own computer.  Yes, I have unchecked the radio button in AD for the user's profile to connect to a home folder.  I then manually mapped it.  The user is going to check it in the next couple of days.
0
 
Mark PavlakCommented:
Ok I was just looking at what if someone  was logging on local to your domain from another PC.  Although you wont cause a problem if you manually mapp and leave it checked
0
 
cheesebugahAuthor Commented:
jfinner2,

Thank you for your help on this matter.  This has been driving us crazy for a long time.  I have always been suspicious of the AD profile setting, but just haven't had a chance to test it.  We're not busy or nothing.  Anyway, I will let you know how it goes in the next day or two.  We are going to be going to a Citrix desktop environment instead of VPN soon, so this won't be an issue through the VPN when we're done with that.

Thanks,
Cheese
0
 
cheesebugahAuthor Commented:
The solution that worked best for me in this situation was to uncheck the AD home folder mapping in AD and then manually map the user's home folder making sure "reconnect at logon" is checked, which is the default.  I have had no further isses since.

Thanks,
Cheese
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now