Jump to content

AD OUS and persistant drives


Recommended Posts

Hi there, 

I have a question about persistent drives and AD. 
I am playing around with a script but I'm missing something. What i want to do is if a user is part of an OU, it will map a network drive and be persistent. However if a user is moved out of that OU, they will need to have the persistent drive removed. 

I'm using the ad plugin script, and i can map the drives if a user is in a specific ou, but i cannot seem to delete the drive if the user is out of the OU. 

Here's an example of code I'm using: 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Fileversion=1.0.0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AD\AD.au3>

func MapDrives()
    _AD_Open()
    
    if _AD_RecursiveIsMemberOf(OU) Then
        Mapdrive1()
    Elseif _AD_RecursiveIsMemberOf(different ou)
    drivemapdel    
    EndIf
    
    _AD_Close()
EndFunc
    
Func MapDrive1()
    Drivemapdel ("Z:")
    DriveMapAdd ("Z:"."\\server\share",$DMA_PERSISTENT,0)
    
EndFunc

 

Link to comment
Share on other sites

Can you add some debugging for example:

func MapDrives()
    _AD_Open()
    
    if _AD_RecursiveIsMemberOf($OU) Then
        Mapdrive1()
        MsgBox(64, $OU, @UserName & " is member of " & $OU & @CRLF & DriveMapGet("Z:"))
    Elseif _AD_RecursiveIsMemberOf($differentou)
        DriveMapDel("Z:")
        MsgBox(64,$differentou, @UserName & " is member of " & $differentou & @CRLF & DriveMapGet("Z:"))
    EndIf
    
    _AD_Close()
EndFunc

 

Link to comment
Share on other sites

Hi there, 

I dont want a message box to pop up when a user signs in, but to have the script detect whether they are apart of a specific ou, and if they were moved into a different ou then the script would remove the previous persistent drive. I think I got the code right, but need to double check it with someone.

Thanks 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...