#136647 - 2005-03-31 09:35 PM
Re: OU instead of Groups
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Nice catch there Howard. Trooper - please don't modify any UDF until you've become more familiar with KiXtart and understand the implcations of your modifications. UDF are designed to be used sort of like a black-box solution. You call them and provide data for them, but don't modify them. Please copy this code below into WORDPAD, then copy again from WORDPAD into either Notepad or some other ASCII editor and save the file as CONTAINER.KIX then call it from DOS console like this so you can view the returned data. Then report back what you saw on screen. Please use KiXtart 4.22 or 4.23KIX32.EXE CONTAINER.KIX Dim $UsersOU $UsersOU = InContainer ('OU=Users,OU=Information Technology,OU=Dublin,DC=lab,DC=iconcr,DC=com' ,'User' )Select Case $UsersOU [0 ]=1 ? "object is a member of the specified container." ? 'T: (\\shortts\DATA)' Use T: '\\shortts\DATA' ? 'Mapping T: drive ERR: ' + @ERROR + ' ' + @SERROR Case $UsersOU [0 ]=2 ? "object is a member of a child container lower in the hierarchy." Case $UsersOU [0 ]=0 ? "object is NOT a member of this container or a child of this container." Case $UsersOU [0 ]=-1 ? "InContainer() Error - Invalid input for $NameType " Case $UsersOU [0 ]=-2 ? "TranslateName() Error" Case 1 ? "Unknown return code" EndSelect Function InContainer ($Container , $NameType ) Dim $Container , $CurrentContainer , $NameType , $Name1 , $Name2 Select Case $NameType = "Computer" $Name1 = "@Domain\@wksta$" Case $NameType = "User" $Name1 = "@LDomain\@UserID" Case 1 $Name1 = "" EndSelect If $Name1 < > "" $Name2 = TranslateName (3 , "" , 3 , $Name1 , 1 ) If $Name2 [1 ] = 0 $CurrentContainer = SubStr ($Name2 [0 ], InStr ($Name2 [0 ], "," )+1 ) Select Case $CurrentContainer =$Container $InContainer = 1 , $Name2 [1 ], $Name2 [2 ] Case InStr ($Name2 [0 ], $Container ) $InContainer = 2 , $Name2 [1 ], $Name2 [2 ] Case 1 $InContainer = 0 , $Name2 [1 ], $Name2 [2 ] EndSelect else $InContainer = -2 , $Name2 [1 ], $Name2 [2 ] EndIf else $InContainer = -1 , 0 , "" EndIf EndFunction Function TranslateName ($InitType , $BindName , $LookupNameType , $LookupName , $ReturnNameType ) Dim $InitType , $BindName , $LookupNameType , $LookupName , $ReturnNameType Dim $NameTranslate , $ReturnName , $Error , $ErrorText $Error = 0 $ErrorText = "" $ReturnName = "" $NameTranslate = CreateObject ("NameTranslate" ) $Error = @ERROR $ErrorText = @serror If $Error = 0 $NameTranslate.Init ($InitType , $BindName ) $Error = @ERROR $ErrorText = @serror If $Error = 0 $NameTranslate.Set ($LookupNameType , $LookupName ) $Error = @ERROR $ErrorText = @serror If $Error = 0 $ReturnName = $NameTranslate.Get ($ReturnNameType ) $Error = @ERROR $ErrorText = @serror EndIf EndIf EndIf $TranslateName = $ReturnName , $Error , $ErrorText Endfunction
Top
Moderator: Jochen , Allen , Radimus , Glenn Barnas , ShaneEP , Ruud van Velsen , Arend_ , Mart
0 registered
and 578 anonymous users online.