Solved

Mapp network drives with user group membership

Posted on 2006-11-03
7
877 Views
Last Modified: 2008-02-01
I would like to map drives based on group membership. I have tried the following but get an error on line 21 Char: 1 error: The specified domain either does not exist or could not be contacted. code:8007054B Source:(null)


Const IT = "cn=it"
Const CORPORATE = "cn=corporate"
Const SERVICES = "cn=services"
Const UNIVERSITY = "cn=university"

' ======================================================
' MAP HOME DRIVE H:
' ======================================================

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\pways50-fs1\Profiles\" & wshNetwork.UserName



' ======================================================
' COMPILE USER GROUP MEMBERSHIPS
' ======================================================

set ADSysInfo = CreateObject("ADSystemInfo")
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
if IsArray(CurrentUser.MemberOf) then
strGroups = LCase(Join(CurrentUser.MemberOf))
' else
'strGroups = LCase(CurrentUser.MemberOf)
end if
'set ADSysInfo = nothing
'set CurrentUser = nothing

' ======================================================
' MAP DRIVES
' ======================================================
If InStr(strGroups, IT) Then

wshNetwork.MapNetworkDrive "i:", "\\pways50-fs1\IT"
'

ElseIf InStr(strGroups, CORPORATE) Then

wshNetwork.MapNetworkDrive "x:", "\\pways50-fs1\corporate"

ElseIf InStr(strGroups, SERVICES) Then

wshNetwork.MapNetworkDrive "s:", "\\pways50-fs1\services"

ElseIf InStr(strGroups, UNIVERSITY) Then

wshNetwork.MapNetworkDrive "u:", "\\pways50-fs1\university"

End If

WScript.Echo "Script is complete."


Two objects for this project. 1) I would like one script to map network drives for my users. 2) After 8 hours i lose my connection to the server. I can either log back in or remap the drives. However i can not map the drives with the user that is logged in. i have to use the administrator account and password for the server.

Sorry for the log post.
thanks for your help.
0
Comment
Question by:nkeever
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:dasmcse
ID: 17869023
To fix the error, try changing the line
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)

to

set CurrentUser = GetObject("GC://" & ADSysInfo.UserName)
0
 

Author Comment

by:nkeever
ID: 17869183
Thanks for the reply. However i get the same error?
0
 
LVL 4

Expert Comment

by:dasmcse
ID: 17874345
Add the following line to the beginning of the script.

on error resume next
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:nkeever
ID: 17880708
So if i resume on error and skip the command to set my currentUser how will the strGroups command work?
0
 
LVL 4

Accepted Solution

by:
dasmcse earned 500 total points
ID: 17883684
On error resume next doesn't skip a line, it just contines to run the script if an error occurs. A error occurs in your script if a network drive is already mapped and you try to map it again. I went through the trouble of setting up a domain controller in a virtual machine and tested your script. It works.
0
 

Author Comment

by:nkeever
ID: 17891319
Ok so maybe my domain is not set up correctly. I am able to get the first drive mapped (wshNetwork.MapNetworkDrive "h:", "\\pways50-fs1\Profiles\" & wshNetwork.UserName) but not the other drives.  the user i am using is only a member for the IT group.

0
 

Author Comment

by:nkeever
ID: 18029672
Thanks for your help dasmcse. I needed to have a DNS server installed to run my script.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordmultiple challenge 12 132
listing all functions in JavaScript 19 201
move one pixel 4 67
Please explain: Aspect Oriented Programming 2 93
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

773 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