#195122 - 2009-07-30 08:17 AM
Check OU...
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
Is the function InOU working on the last kixtart.
I need to map some shares to all users of a OU and it doesn't work...
Just open a command line window with the name of the OU.
The idea is simple.
If user belong to OU then map the drive x:\xxxxxxxx
How can i do that?
|
|
Top
|
|
|
|
#195123 - 2009-07-30 09:25 AM
Re: Check OU...
[Re: vdias]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Could go from here:
Dim $objSysInfo
$objSysInfo = CreateObject("ADSystemInfo")
? "User name: " + $objSysInfo.UserName
From there you can check for the OU you are searching for.
|
|
Top
|
|
|
|
#195124 - 2009-07-30 09:51 AM
Re: Check OU...
[Re: Arend_]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
But how do i put that on the kx file?
In my netlogon i point to a .bat that executes wkis32.exe map.kx...
Where do i put that code?
|
|
Top
|
|
|
|
#195127 - 2009-07-30 10:25 AM
Re: Check OU...
[Re: Arend_]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
This is not the fastest way to implement it but it gives you an idea of how it works:
Dim $objSysInfo, $arrDN, $strDN
$objSysInfo = CreateObject("ADSystemInfo")
$arrDN = Split($objSysInfo.UserName,",")
For Each $strDN in $arrDN
If $strDN = "OU=TheNameOfMyOU"
Use X: \\server\share
EndIf
Next
|
|
Top
|
|
|
|
#195128 - 2009-07-30 10:43 AM
Re: Check OU...
[Re: Arend_]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
If InOU(XXXXX)=1 use T: "\\XXXX\XXX" EndIf
Why something doesn't work too?
|
|
Top
|
|
|
|
#195130 - 2009-07-30 11:02 AM
Re: Check OU...
[Re: Mart]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
|
|
Top
|
|
|
|
#195131 - 2009-07-30 11:08 AM
Re: Check OU...
[Re: Mart]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Ok, found a InOU() function at scriptlogic. http://www.scriptlogic.com/kixtart/FunctionLibrary_ViewFunction.aspx?ID=InOU
The example below works but you can only check one OU. If a user is a member of the users OU in the Finance OU and an other user is a member of the Users OU in the Warehouse OU then it will both return 1 (is a member). Maybe it can be altered a bit to support sub OU's but I have time to figure out what to modify right now.
Break on
$IsComputer = ""
$OUName = "Users"
$rc = InOU($OUName, $IsComputer)
? $rc
Sleep 5
Function InOU($OUName, Optional $IsComputer) ; (Standalone version restricted to Windows 2000 and XP systems)
Dim $OUelement
If Len($IsComputer) > 0
$IsComputer = 1
Else
$IsComputer = 0
EndIf
$InOU = 0
If Len($_InOUUser) > 0 And Len($_InOUComputer) > 0
If $IsComputer = 0
If $_InOUUser = "Initialized but no OU available"
Return
EndIf
For Each $OUelement in Split($_InOUUser, ",")
If $OUElement = $OUName $InOU = 1 EndIf
Next
Else
If $_InOUComputer = "Initialized but no OU available"
Return
EndIf
For Each $OUelement in Split($_InOUComputer, ",")
If $OUElement = $OUName $InOU = 1 EndIf
Next
EndIf
Else
$sysinfo = CreateObject("adsysteminfo")
If $sysinfo <> 0
For Each $OUelement in Split($sysinfo.username, ",")
If Left($OUelement, 3) = "OU="
$_InOUUser = $_InOUUser + SubStr($OUelement, 4) + ","
If $IsComputer = 0
If SubStr($OUelement, 4) = $OUName $InOU = 1 EndIf
EndIf
EndIf
Next
If Len($_InOUUser) = 0
$_InOUUser = "Initialized but no OU available"
EndIf
For Each $OUelement in Split($sysinfo.computername, ",")
If Left($OUelement, 3) = "OU="
$_InOUComputer = $_InOUComputer + "," + SubStr($OUelement, 4)
If $IsComputer = 1
If SubStr($OUelement, 4) = $OUName $InOU = 1 EndIf
EndIf
EndIf
Next
If Len($_InOUComputer) = 0
$_InOUComputer = "Initialized but no OU available"
EndIf
EndIf
EndIf
EndFunction
Edited by Mart (2009-07-30 11:09 AM)
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#195132 - 2009-07-30 11:10 AM
Re: Check OU...
[Re: Mart]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
Mart, where do i put all this code? on the kx file?
|
|
Top
|
|
|
|
#195134 - 2009-07-30 11:37 AM
Re: Check OU...
[Re: Mart]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
something must be wrong...
Copy+paste all code from
Function InOU($OUName, Optional $IsComputer) ; (Standalone version restricted to Windows 2000 and XP systems)
to
Endfunction
and after add...
If InOU ("XXXXXXX")=1 use Q: "\\XXXXX\XXX" EndIF
and it nothing happens...
|
|
Top
|
|
|
|
#195138 - 2009-07-30 12:54 PM
Re: Check OU...
[Re: Glenn Barnas]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
Glenn,
Just copy all code to my mapdrive.kx
and after wrote...
If InOU ("XXXXXXX")=1 use Q: "\\XXXXX\XXX" EndIF
and nothing happens...
Can you send me a example or something...
|
|
Top
|
|
|
|
#195165 - 2009-07-31 08:16 AM
Re: Check OU...
[Re: Gargoyle]
|
vdias
Fresh Scripter
Registered: 2009-07-29
Posts: 8
Loc: Villaverde del Rio, Sevilla, S...
|
Everything working now...
Using Glenn udf (thanks a lot Glenn!) and the following code:
If InOu (XXXXXXXXX) use Q: "\\XXXX\XXXXX\XXXXX" use X: "\\XXXX\XXXXX\XXXXX" Shell "xxxxxxxxxxxxxxxxxxxxx" EndIf
Thanks a lot to everyone!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|