+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, Script to map drive by OU in Coding and Web Development; I'm sure I saw an example VB script here somewhere with the code for mapping drives by user OU location, ...
  1. #1
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,201
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74

    Script to map drive by OU

    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?

    Thanks.

  2. #2
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Map Network drive dependant on Comp OU
    By buzzard in forum Scripts
    Replies: 1
    Last Post: 13th August 2009, 03:45 PM
  2. Kix Map Drive
    By Bongo in forum Scripts
    Replies: 4
    Last Post: 5th June 2008, 08:40 AM
  3. Different Map Drive for different ICT rooms
    By Jimbob in forum How do you do....it?
    Replies: 3
    Last Post: 14th September 2007, 09:35 AM
  4. Map FTP as Drive?
    By Samson in forum Scripts
    Replies: 1
    Last Post: 2nd July 2007, 08:34 AM
  5. VBS Drive script is running from
    By Samson in forum Scripts
    Replies: 5
    Last Post: 10th May 2007, 03:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •