Richard
Mon Feb 09 23:06:09 CST 2004
shawne wrote:
> A client that I am working with is trying to write a login script to
connect users from different ou's (groups)to various shares and map the
drives as they log in. Can this be done? Is this proposed solution a good
work around for not using XP and group policies and where on earth would
they start ?
Hi,
Yes, it can be done, if I understand what you want. A lot depends on the
client OS's supported. Group Policy can be applied to OU's, so each OU has
it's own logon script. If you don't use Group Policy, you can assign a logon
script to each user in AD Users & Computers on the "Profile" tab. You could
give each user their own logon script, or use one script for everyone. If
the clients have ADSI, you can test group membership and map drives
accordingly. If you want to map according to OU, then you must retrieve the
Distinguished Name of the user and parse this for the OU. For example, if
the client OS is at least W2k, you can use the ADSystemInfo object, as
follows:
' Retrieve user Distinguished Name.
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
' Parse for the Distinguished Name of the parent OU.
intIndex = InStr(LCase(strUserDN), "ou=")
If intIndex > 0 Then
strOU = Mid(strUserDN, intIndex)
End If
' Test if user in ou=Sales.
If LCase(strOU) = "ou=sales,dc=MyDomain,dc=com" Then
... map drive or whatever.
End If
For sample logon scripts, and a FAQ on logon scripts:
http://www.rlmueller.net/freecode2.htm
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site -
http://www.rlmueller.net
--