+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, Map Network drive dependant on Comp OU in Coding and Web Development; Hi all, apologies for this, I've done it before but forgot the exact code! I need a logon vbs to ...
  1. #1
    buzzard's Avatar
    Join Date
    May 2006
    Location
    North West
    Posts
    309
    Thank Post
    106
    Thanked 28 Times in 24 Posts
    Rep Power
    25

    Map Network drive dependant on Comp OU

    Hi all, apologies for this, I've done it before but forgot the exact code!

    I need a logon vbs to check if the user logging on is on a computer in the "admin" ou which houses the Admin PC's. If the answer is yes then Map the network drive... for the life of me I can't get what I did last time where I used to work...

    TIA

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    This should get you started:
    Code:
    set oNet=createobject("wscript.network")
    set oSysinfo=createobject("adsysteminfo")
    
    'get full name eg cn=pc010203,ou=finance,ou=allpcs,dc=ic,dc=ac,dc=uk
    sDN=lcase(oSysinfo.computername)
    
    'separate at commas; sdata(0) will be cn=pc010203; sdata(1) will be ou=finance etc
    sData=split(sDN,",")
    
    sOU=mid(sdata(1),4) 'get the lowest level OU - finance here - and start at 4th char; ie lose "ou="
    
    'find the path to map for this OU
    select case sOU
      case "finance"
        sPath="\\server1\fin_data"
      case "admin"
        sPath="\\server2\adminstuff"
    end select
    
    'and map it
    
    if sPath<>"" then
      oNet.mapnetworkdrive "Z:",sPath
    end if

SHARE:
+ Post New Thread

Similar Threads

  1. Kix Map Drive
    By Bongo in forum Scripts
    Replies: 4
    Last Post: 5th June 2008, 08:40 AM
  2. Network Map
    By onder in forum General Chat
    Replies: 16
    Last Post: 31st January 2008, 11:03 AM
  3. Map network drives on wireless network
    By woody in forum Windows
    Replies: 24
    Last Post: 1st December 2007, 06:27 PM
  4. 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
  5. Map FTP as Drive?
    By Samson in forum Scripts
    Replies: 1
    Last Post: 2nd July 2007, 08:34 AM

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
  •