#148895 - 2005-09-30 10:30 AM
Read out the OU and the Group memberchip
|
mcordes
Fresh Scripter
Registered: 2005-09-30
Posts: 5
Loc: Germany
|
Hi,
I search a Variable or somethink to read out the OU (windows 2003 server) and the group in which a person is. For example: mcordes is in the OU "IT" and in the group "Administratoren" and in the group "IT-GROUP". Know I want to show me the OU and the group in a script. I didn´t want to ask in the skript if ingroup ("Administratoren") ?"In group Administratoren ..."
I want ?"You are in the OU " inou ?"You are in the groups " inthegroups
Thanks for you help.
(and my bad englisch, bat I could not find a german forum :-( )
bye
mc
|
|
Top
|
|
|
|
#148896 - 2005-09-30 01:18 PM
Re: Read out the OU and the Group memberchip
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
|
|
Top
|
|
|
|
#148897 - 2005-09-30 01:53 PM
Re: Read out the OU and the Group memberchip
|
mcordes
Fresh Scripter
Registered: 2005-09-30
Posts: 5
Loc: Germany
|
Hi, thank you for your fast answer, but if I insert your code, I get an error.
unknown command [ADSystemInfo]!
Over that error message signed:
Function fnInGroupAD($sGroup,Optional $bComputer) Dim $objSys,$objTarget,$aMemberOf,$sMemberOf $objSys = CreateObject("ADSystemInfo") $objTarget = GetObject(
If I insert the other code, I get this error message: unknown command [ADSystemInfo]!
Function GetUserOU() Redim $TempArray[0] Redim $GetUserOU $adSys = CreateObject(
What´s wrong? I hope you can help me.
thank´s and see you
michael
|
|
Top
|
|
|
|
#148898 - 2005-09-30 02:18 PM
Re: Read out the OU and the Group memberchip
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Yeah that function has bitten me also. Weird function, bad examples. Cant get the user ou to work yet. Should have tried it before givving the link  The group goes like this:
Code:
$group = "Domain Admins"
If fnInGroupAD($group) ?"The user is a member of " + $group + "." Sleep 3 Else ?"The user IS NOT a member of " + $group + "." EndIf
;Function: ; fnInGroupAD() ; ;Author: ; Christopher Shilt (christopher.shilt@relizon.com) ; ;Version: ; 1.0 (June 22, 2005) ; ;Version History: ; ;Action: ; Determines if a user or computer is a member of an Active Directory Group ; ;Syntax: ; fnInGroupAD(GROUP, Optional MODE) ; ;Parameters: ; WHAT : Required. Group to test for membership of. ; ; MODE : Optional. Specifies whether to search the group membership For ; the current user account or the current computer account. ; MODE = 0 (user) ; MODE = 1 (computer) ; ;Remarks: ; ; This function is meant to compliment KiXtart's built-in InGroup function, not ; replace or mimic it's functionality. The built-in InGroup function cannot test ; for membership of computer accounts or Universal groups. ; ;Returns: ; ; 0 The user or computer IS NOT a member of a group with this name ; 1 The user or computer IS a member of a group with this name ; ;Dependencies: ; ; ;Example: ; ; ; == Test the functionality of the built-in InGroup ============= ; If InGroup("TestUniversalGroup") ; "This will always be false" ? ; EndIf ; ; ; == Test if the current user is a member of a group ============ ; If fnInGroupAD("TestUniversalGroup") ; "The user is a member of the TestUniversalGroup" ? ; EndIf ; ; ; == Test if the current computer is a member of a group ======= ; If fnInGroupAD("TestUniversalGroup",1) ; "The computer is a member of the TestUniversalGroup" ? ; EndIf ; ; Function fnInGroupAD($sGroup,Optional $bComputer) Dim $objSys,$objTarget,$aMemberOf,$sMemberOf $objSys = CreateObject("ADSystemInfo") $objTarget = GetObject("LDAP://"+IIf($bComputer,$objSys.ComputerName,$objSys.UserName)) $aMemberOf = $objTarget.GetEx("memberOf") For Each $sMemberOf in $aMemberOf If InStr($sMemberOf,"CN="+$sGroup+",") $fnInGroupAD = NOT 0 Exit EndIf Next $fnInGroupAD = NOT 1 EndFunction
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#148899 - 2005-09-30 02:37 PM
Re: Read out the OU and the Group memberchip
|
mcordes
Fresh Scripter
Registered: 2005-09-30
Posts: 5
Loc: Germany
|
hmm,
with your script is the same problem. :-(
here the error message: $group= ERROR: unknown command [Administratoren]!
Whatever I insert vor Administratoren, the errorcode is the same.
And know?
michael
|
|
Top
|
|
|
|
#148900 - 2005-09-30 03:18 PM
Re: Read out the OU and the Group memberchip
|
mcordes
Fresh Scripter
Registered: 2005-09-30
Posts: 5
Loc: Germany
|
Oh, and know the next problem. I have no function bis this code. addprinterconnection ("\\win2003server\HPLaserJ")
the name of the windows 2003 server ist: win2003server and the printer on LTP1 is release at: HPLaserJ
the error code is: ADDPRINTERCONNECTION 8 unknown command ["\\win2003server\HPLaserJ"]
If I insert the \\win2003server\HPLaserJ manual in the explorer, a popup open to install the printerdriver.
What´s wrong?
I haven´t installed a dll or something else. I start the kix32.exe and the test.kix file with a batch file
start.bat \\win2003server\loginskripte\kix32.exe \\win2003server\loginskripte\start.kix
Thank you and a nice and lang weekend.
See you. cordes
|
|
Top
|
|
|
|
#148902 - 2005-09-30 09:49 PM
Re: Read out the OU and the Group memberchip
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Also give us the version of KiXtart you are using.
the TranslateName() UDF can also get you the Users distinguished or canonical name given the domain\user NT format.
|
|
Top
|
|
|
|
#148903 - 2005-10-04 12:05 AM
Re: Read out the OU and the Group memberchip
|
mcordes
Fresh Scripter
Registered: 2005-09-30
Posts: 5
Loc: Germany
|
Hi and good evening,
thank´s for your fast help.
I use the Kix Version: KiXtart 2010 4.50 KiX2010_450.zip (643kB)
And yes, I insered all code of your post. But if you say, that it works in your script, I test it tomorrow at my work.
But one question: Is it right, that you search for the group "Domain Admins"?
$group = "Domain Admins"
If fnInGroupAD($group) ?"The user is a member of " + $group + "." Sleep 3 Else
But how could I search for the OU (disposition or purchase or IT...)
Thank you and I answer you what happend with my / your script.
Howard Bullock: What does you mean with the TranslateName(). How could I use it?
Thank´s and bye
mcordes
ps. I now it, I´m a scipt "DAU". In German is it:"Dümmster anzunehmender User" I think in english is it "the addlebrained maximum credible accident user" ;-)
bye
|
|
Top
|
|
|
|
#148905 - 2005-10-04 03:37 PM
Re: Read out the OU and the Group memberchip
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
TranslateName() is a UDF (see manual and FAQ forum) that I wrote which translate names domain\user to distinguished name etc. You can find this UDF in the UDF forum.
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1283 anonymous users online.
|
|
|