Re: Drive maping help
- From: "Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 19:21:41 -0700
Thanks for doing the legwork on this one, Marty! ;-)
But wait a minute. On second reading of your script, it seems to me that
function "CheckOUMembership" will return a TRUE value if the specified OU
contains ANY objects of type "USER". Seems to me it should be doing this
only if the user found has the same name as what is stored in the "Account"
parameter.
Using the OU is probably the simplest way to ensure each user has only one
"affiliation" or "membership". Just remember that OU membership has other
uses than to organize drive mappings. If your IT department decides, for
example, to collapse OU's because they are changing their account
administration model, well, you will need to be able to deal with the
result.
To make this approach a bit scaleable, I would be tempted to avoid the
literal approach of: if in this OU do this, elseif in this other OU do this.
Specifically, I would determine the user's OU as being the parent of his
distinguished name, concatenate the OU names (i.e. "Accounting-Department"),
look for a file of that name on the domain controller, and read the name of
the drive to map from that file. This approach also avoids having to
enumerate all objects in the OU in question.
/Al
"Marty List" <usenet@xxxxxxxxxxxx> wrote in message
news:uIleRy1UGHA.5592@xxxxxxxxxxxxxxxxxxxxxxx
probably a
Jim,
Try this script, I think this is what you are asking for. There's
faster/more efficient way of doing this, and personally I would use moreobjAccount.FullName
variable names, but this way should be easier to understand if you're just
getting started.
'===========================================
Option Explicit
Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")
' Fix this next line if it wrapped, If .... Then should be on one line:
If CheckOUMembership(WSHNetwork.username,
"LDAP://OU=Accounting,OU=Departments,DC=domain,DC=com") Then
WScript.Echo "DEBUG: Mapping drive T:"
WSHNetwork.MapNetworkDrive "T:", "\\SERVER\Share$"
End If
WScript.Quit
Function CheckOUMembership(ByVal Account, ByVal OU)
CheckOUMembership = False
Dim objAccount, objDomain
Set objAccount = Nothing
Set objDomain = GetObject(OU)
For Each objAccount in objDomain
' The object class can be User, Group, Computer or Schema.
If UCase(objAccount.Class) = "USER" Then
'WScript.Echo "DEBUG: " & objAccount.Name & ": " &
CheckOUMembership = Truegroups is
Exit For
End If
Next
End Function
'===========================================
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E66E1A75-BCDB-4C57-A2D4-A37EC272B766@xxxxxxxxxxxxxxxx
Al
Thank you; you deciphered what I needed perfectly
One last question to solve the issue of the user being in multiple
map?it possible instead to use the Organizational Units name to setup the T:
Group
Thanks again
Jim
"Al Dunbar [MS-MVP]" wrote:
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0E2D6115-AF77-4B01-95C2-B05D40104404@xxxxxxxxxxxxxxxx
when a user logs in i would like this script to run as part of a
possible topolicy
to automatically map drive T and V for every user. also is it
user,change the groupname variable
hold on, your script does not reference a groupname variable.
so that if for example the groupname = "PR_grp"
that the T: drive is mapped to \\servername\Payroll
=========
Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")
WSHNetwork.MapNetworkDrive "T:", "\\Servername\Groupname"
WSHNetwork.MapNetworkDrive "V:", "\\Servername\logonname"
As written, the above code will map a share whose name is, literally
"groupname" on a server whose name is "servername" to drive T: and to
similarly map a share whose name is "logonname".
If your intention is that the actual sharenames differ from user to
WSHNetwork.usernamethe simplest one to implement is V:
WSHNetwork.MapNetworkDrive "V:", "\\Servername\" &
user"
If the user account is named "ElmerFudd", then V: would map to
\\Servername\ElmerFudd.
This is pretty straightforward, because the concept: "name of current
memberships tois understood by all parties. What is not clear is what you refer to as
"groupname", as this has no particular meaning here.
What I suspect you want is along these lines:
if user is in the group named "PR_grp" then
map T: to \\servername\Payroll
elseif user is in the group named "FI_grp" then
map T: to \\servername\Finance
... etc ...
The trouble is that there is nothing to constrain ones group
whenonly one of a set number of groups. What should T: map to, for example,
users.the user is found to be a member of PR_grp and FI_grp?
/Al
==========
the servername i will fill in. what i need help with is Groupname and
Username so i dont have to create over 200 of these for all of our
OUname as
after thinking a little more on this the groupname should be the
itthey could be a member of many groups but only one OU
jim
"Marty List" wrote:
Explain what you mean by "insert". To me that means type or paste
trying tointo
Notepad, but I doubt that's what you need help on :) Are you
to?pass
variables to the script on the command line?
When you say "a script", which scripting language are you referring
mapDo you
already have a script or a sample you're working with?
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D7FE7947-06BC-4972-82C8-EE4428899FD8@xxxxxxxxxxxxxxxx
is there a way to insert the user and group name into a script to
network drives?
thanks
Jim
.
- Follow-Ups:
- Re: Drive maping help
- From: Marty List
- Re: Drive maping help
- References:
- Re: Drive maping help
- From: Marty List
- Re: Drive maping help
- From: Al Dunbar [MS-MVP]
- Re: Drive maping help
- From: Jim
- Re: Drive maping help
- From: Marty List
- Re: Drive maping help
- Prev by Date: Re: [MSH] Something I still do not understand
- Next by Date: Re: [MSH] Something I still do not understand
- Previous by thread: Re: Drive maping help
- Next by thread: Re: Drive maping help
- Index(es):
Relevant Pages
|
Loading