Re: Drive maping help




Jim,

Try this script, I think this is what you are asking for. There's probably a
faster/more efficient way of doing this, and personally I would use more
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 & ": " & objAccount.FullName
CheckOUMembership = True
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 groups is
it possible instead to use the Organizational Units name to setup the T: map?

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 Group
policy
to automatically map drive T and V for every user. also is it possible to
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 user,
the simplest one to implement is V:

WSHNetwork.MapNetworkDrive "V:", "\\Servername\" & WSHNetwork.username

If the user account is named "ElmerFudd", then V: would map to
\\Servername\ElmerFudd.

This is pretty straightforward, because the concept: "name of current user"
is 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 memberships to
only one of a set number of groups. What should T: map to, for example, when
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 users.

after thinking a little more on this the groupname should be the OUname as
they 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 it
into
Notepad, but I doubt that's what you need help on :) Are you trying to
pass
variables to the script on the command line?

When you say "a script", which scripting language are you referring to?
Do 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 map
network drives?


thanks
Jim









.



Relevant Pages

  • Re: Drive maping help
    ... your script does not reference a groupname variable. ... Set WSHNetwork = WScript.CreateObject ... As written, the above code will map a share whose name is, literally ... When you say "a script", which scripting language are you referring to? ...
    (microsoft.public.windows.server.scripting)
  • Re: Drive maping help
    ... Try this script, I think this is what you are asking for. ... Set WSHNetwork = WScript.CreateObject ... your script does not reference a groupname variable. ... As written, the above code will map a share whose name is, literally ...
    (microsoft.public.windows.server.scripting)
  • Re: Drive maping help
    ... it possible instead to use the Organizational Units name to setup the T: map? ... your script does not reference a groupname variable. ... the user is found to be a member of PR_grp and FI_grp? ... When you say "a script", which scripting language are you referring to? ...
    (microsoft.public.windows.server.scripting)
  • Newbie: Why does SAMBA authentication fail?
    ... The problem is I can't map a drive to it from my Win XP box. ... ldap delete dn = No ...
    (comp.os.linux.misc)
  • Re: Drive maping help
    ... Dim objAccount, objDomain ... Set objDomain = GetObject ... Try this script, I think this is what you are asking for. ... As written, the above code will map a share whose name is, literally ...
    (microsoft.public.windows.server.scripting)