
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