Sign in to follow this  
Followers 0
jazzyjeff

Login Script

4 posts in this topic

Hi,

I am using the following script to map network drives based on user group membership:

#include<AD.au3>

DriveMapDel ("H:")
DriveMapDel ("I:")
DriveMapDel ("J:")
DriveMapDel ("K:")
DriveMapDel ("L:")
DriveMapDel ("M:")
DriveMapDel ("N:")
DriveMapDel ("O:")
DriveMapDel ("P:")
DriveMapDel ("Q:")
DriveMapDel ("R:")
DriveMapDel ("S:")
DriveMapDel ("V:")
DriveMapDel ("W:")
DriveMapDel ("X:")
DriveMapDel ("Y:")
DriveMapDel ("Z:")

Global $aUser, $sFQDN_Group, $sFQDN_User, $iResult

; Open Connection to the Active Directory
_AD_Open()

; Get the Fully Qualified Domain Name (FQDN) for the current user
$sFQDN_User = _AD_SamAccountNameToFQDN()

; Get an array of group names (FQDN) that the current user is immediately a member of
$aUser = _AD_GetUserGroups(@UserName)
$sFQDN_Group = $aUser[1]

; Check the group membership of the specified user for the specified group
$iResult = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User)

Select
    Case $iResult = "Domain Admins"
        DriveMapAdd("M:","\\app2\K5-Staff")
        DriveSetLabel("M:\","M Drive - Apps")
        DriveMapAdd("N:","\\app2\K5-Common")
        DriveSetLabel("N:\","N Drive - Common Apps")
        DriveMapAdd("T:","\\staffshare1\departmentshares$\Technology")
        DriveSetLabel("T:\","T Drive - Technology")
        DriveMapAdd("X:","\\techstore1\toolbox$")
        DriveSetLabel("X:\","X Drive - Toolbox")
        DriveMapAdd("Y:","\\techstore1\toolbox$\Deployment Drive\Elementary")
        DriveSetLabel("Y:\","Y Drive - Deployment")
        DriveMapAdd("Z:","\\StaffStore2\Userdata$\" &@UserName)
        DriveSetLabel("Z:\","Z Drive - " & @UserName & " - Home Directory")
EndSelect

; Close Connection to the Active Directory
_AD_Close()

The drive mapping part works fine, but the labels work for some of the drives and not others. Why is this? I am guessing my code is ok if it works for some of the drives, but maybe there is a problem with the "DriveSetLabel" function?

I have attached an image to help understand what I mean.

The drives should read:

M Drive - Apps

N Drive - Common Apps

T Drive - Technology

etc..

Thanks in advance for any help.

Jeff

post-54196-12748847013954_thumb.jpg

Share this post


Link to post
Share on other sites



Are you sure you want to do the "DriveSetLabel" in your login script?

I understand that "DriveSetlabel" writes the volume label to the disk. But that's something you do when you create the disk. That means once and not at every logon.

I recommend to remove the "DriveSetLabels" from your login script and set the labels once manually.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Water,

Thanks for the response. I understand what you are saying about the drive label being used once.

I am currently using a Kix script with the MapDrive UDF that achieves the results. Unfortunately, the script takes a long time to finish executing (almost a minute). The AutoIT script finishes in seconds.

The time it completes the task is pretty critical as the teachers and students at my school assume everything is going to be ready as soon as they log in.

We set the labels on the drive because it made it easier for the users to see what drive they were looking at. Now that we have implemented, it will be tough to take away, as I can imagine a few people complaining.

I am going to try a suggestion in this article.

http://www.autoitscript.com/forum/index.php?showtopic=22041

I'll post a response when I get to test it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0