Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBScript Logon Script

Posted on 2009-05-20
9
612 Views
Last Modified: 2012-05-07
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
Comment
Question by:cheesebugah
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24436718
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
 

Author Comment

by:cheesebugah
ID: 24436853
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
 
LVL 6

Accepted Solution

by:
Mark Pavlak earned 500 total points
ID: 24441060
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:cheesebugah
ID: 24476672
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
 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24477573
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
 

Author Comment

by:cheesebugah
ID: 24477658
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
 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24477735
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
 

Author Comment

by:cheesebugah
ID: 24477762
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
 

Author Comment

by:cheesebugah
ID: 24597136
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question