I'm sure I saw an example VB script here somewhere with the code for mapping drives by user OU location, I currently do this by group membership but could do with an option to map by OU.
Can anyone point me to a thread?
You may find the following functions of use;
These simply work by using the ADSystemInfo object which can return the AD path of the user or computer account in the form CN=user,OU=students,OU=users,DC=domain,DC=root. It's then a simple InStr to see if whatever is sent as a parameter appears somewhere in the string. This does mean that you have to be a bit careful with the parameter as asking for a match with 'Students' would return a positive if the OU 'NonStudents' was somewhere in the path!! Easiest to use a parameter in the form 'OU=full OU name,'
Code:' Check if user is member of an Organisational Unit Function UserInOU(sOU) ' Returns true if the user is a member of the specified OU (or descendant) Dim oAdSys, sUserDN Set oAdSys = CreateObject("ADSystemInfo") sUserDN = UCase(oAdSys.UserName) UserInOU = (InStr(1, sUserDN, UCase(sOU)) > 0) End function ' Check if Computer is a member of an Organisational Unit Function ComputerInOU(sOU) ' Returns true if the computer is a member of the specified OU (or descendant) Dim oAdSys, sComputerDN Set oAdSys = CreateObject("ADSystemInfo") sComputerDN = UCase(oAdSys.ComputerName) ComputerInOU = (InStr(1, sComputerDN, UCase(sOU)) > 0) End Function
There are currently 1 users browsing this thread. (0 members and 1 guests)