Newbie help needed with a Logon Script 
Author Message
 Newbie help needed with a Logon Script

Hi

I am trying to create a logon script that will map out drives for users
based on there group membership in the Active Directory.  i.e a user in the
sales group mapped will have an f: drive that points to the share
\\server1\data\sales is there a way to do this that is straight forward for
me?  Can this be done with the use of ifmember or findgrp in the resource
kit?

Thanks for any help

Jeff



Mon, 29 Aug 2005 00:56:52 GMT  
 Newbie help needed with a Logon Script
' If you're on Windows 2000 Server you can use this:
' Pass the NT Style Domain name and the WshNetwork.UserName
' to the function i.e.:
PrimeGroup= PrimGrpname("MyDomain","JDoe")

' then map like this:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "G:", "\\mypath\shared\"&PrimGrpName

' begin function
Function PrimGrpName(dspath,user)
' Mr. Lee
' 2002 AD Retrieve Primary Group Name from AD user.
'Bind to the user using the WinNT  provider
    set usr = GetObject("WinNT://"&dspath&",user")

   'that will give you the Primary GroupID ( A number)
      PrimGrpId = usr.PrimaryGroupID
      On Error Resume Next
' look at each group the user is a member of.
      For Each grp In Usr.Groups
         GroupName = grp.Name
         Set oGroup = CreateObject("NameTranslate")
 ' translate the name into cn= dc= etc.. LDAP style
         ogroup.Set 3, sDomain & "\" & Groupname
         sFQDN = oGroup.Get(1)
         Set oDSGroup = GetObject("LDAP://"&sfqdn)
   ' now Bind to that translated name.
         oDSGroup.GetInfoEx Array("PrimaryGroupToken"),0
         PrimGrpToken = oDSGroup.Get("PrimaryGroupToken")
         If PrimGrpToken = PrimGrpId then
       if you got in here, you have the primary group name,
       'now you can map based on that
            PrimGrpName = grp.Name
            Exit Function
         End If
      Next
End Function


Quote:
> Hi

> I am trying to create a logon script that will map out drives for users
> based on there group membership in the Active Directory.  i.e a user in
the
> sales group mapped will have an f: drive that points to the share
> \\server1\data\sales is there a way to do this that is straight forward
for
> me?  Can this be done with the use of ifmember or findgrp in the resource
> kit?

> Thanks for any help

> Jeff



Mon, 29 Aug 2005 04:44:59 GMT  
 Newbie help needed with a Logon Script
left one piece out.
Sorry.
dspath sould equal the domain & User ID.   I fixed it below.

Like this:
dspath= sDomain & "/" & sUserID

Quote:

> ' If you're on Windows 2000 Server you can use this:
> ' Pass the NT Style Domain name and the WshNetwork.UserName
> ' to the function i.e.:
> PrimeGroup= PrimGrpname("MyDomain","JDoe")

> ' then map like this:
> Set WshNetwork = WScript.CreateObject("WScript.Network")
> WshNetwork.MapNetworkDrive "G:", "\\mypath\shared\"&PrimGrpName

> ' begin function
> Function PrimGrpName(sDomain,suser)

dspath= sDomain & "/" & sUser
Quote:
> ' Mr. Lee
> ' 2002 AD Retrieve Primary Group Name from AD user.
> 'Bind to the user using the WinNT  provider
>     set usr = GetObject("WinNT://"&dspath&",user")

>    'that will give you the Primary GroupID ( A number)
>       PrimGrpId = usr.PrimaryGroupID
>       On Error Resume Next
> ' look at each group the user is a member of.
>       For Each grp In Usr.Groups
>          GroupName = grp.Name
>          Set oGroup = CreateObject("NameTranslate")
>  ' translate the name into cn= dc= etc.. LDAP style
>          ogroup.Set 3, sDomain & "\" & Groupname
>          sFQDN = oGroup.Get(1)
>          Set oDSGroup = GetObject("LDAP://"&sfqdn)
>    ' now Bind to that translated name.
>          oDSGroup.GetInfoEx Array("PrimaryGroupToken"),0
>          PrimGrpToken = oDSGroup.Get("PrimaryGroupToken")
>          If PrimGrpToken = PrimGrpId then
>        if you got in here, you have the primary group name,
>        'now you can map based on that
>             PrimGrpName = grp.Name
>             Exit Function
>          End If
>       Next
> End Function



> > Hi

> > I am trying to create a logon script that will map out drives for users
> > based on there group membership in the Active Directory.  i.e a user in
> the
> > sales group mapped will have an f: drive that points to the share
> > \\server1\data\sales is there a way to do this that is straight forward
> for
> > me?  Can this be done with the use of ifmember or findgrp in the
resource
> > kit?

> > Thanks for any help

> > Jeff



Mon, 29 Aug 2005 04:48:28 GMT  
 Newbie help needed with a Logon Script

Quote:

> I am trying to create a logon script that will map out drives for users
> based on there group membership in the Active Directory.  i.e a user in the
> sales group mapped will have an f: drive that points to the share
> \\server1\data\sales is there a way to do this that is straight forward for
> me?  Can this be done with the use of ifmember or findgrp in the resource
> kit?

Hi

http://groups.google.com/groups?as_q=group%20membership&safe=images&i...

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Mon, 29 Aug 2005 06:25:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Logon Script Help - newbie

2. Need help with logon script

3. Help: Manual or Reference on Logon Script needed

4. Logon Script Problems - help needed

5. Need help with logon script

6. Newbie needing help with VBS Scripting

7. Newbie needs help, clueless about scripting

8. Please, Need help with windows script - newbie

9. Newbie needs help (making scripts wait for apps to end)

10. Newbie needs ActiveX and VB Script help....

11. Please, Need help with windows script - newbie

12. Newbie needs help scripting outlook to send a message

 

 
Powered by phpBB® Forum Software