#129108 - 2004-11-08 04:38 PM
How to find an OU?
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
Hi, Iīm getting a bit frustated..
Recently we got from the stoneage (NT4) to the here and now, with AD2003. Iīm lost. In my own AD forest. As you can (or cannot) imagine a lot has changed scriptwise..
anyways: what I want to do is search the domain for a given OU. i.e. I need the full LDAP path to the OU sales.
I know how to search for groups, Users, even enumerate Ouīs. but how do I find OUīs?
itīs probably childishly easy, but I canīt find it, and now, after a day of searching (here, on MSDN, etc) I give up. please help.
|
|
Top
|
|
|
|
#129110 - 2004-11-08 04:51 PM
Re: How to find an OU?
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Tell you what I do, I wrote a little utility called ASEPathFinder, you can get it here:
ASEPathFinder
Just run it and select which protocol path you want (WinNT or LDAP), then click location and select your domain, then click advanced and you can search your domain ...
At the end of dialog, the "path" is returned into the dialog box, then you can just easy cut-and-paste the string into your script, like this:
$object = createobject("<the string>")
And Bob's your uncle ... is this what you meant by "search for groups" etc ? Or you talking about searching in the script itself ?
-Shawn
|
|
Top
|
|
|
|
#129113 - 2004-11-08 05:04 PM
Re: How to find an OU?
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
fast....  DSquery.. thanks, found that already, but thatīs not what I need. lets give some more info.. why do I need it: Iīm trying to create a script which moves users form 1 part of our org to another. letīs say a user is in sales and gets a new job in another department, letīs say HR.
my script(s) (as far as the parts are ready) deletes the user from the sales groups, add him to the HR groups, moves the mailbox to the different Exchange 2003 store, moves his profile to the different profile share (letīs say server\HRprofiles) the same for his homedir. and the last thing I need to do is move this user from the sales OU to the HR OU. but since our organisation is quite large we have 60+ OUīs. I can create a "table" in my script, like
if "$newgroup"="HR" $newou="OU=xyz,OU=XYZ2,OU=HR,DC=company,DC=loc" endif (or case select, whatever)
but since this is high maintainance I donīt want it. I want to search in the AD with KIX for this new OU , and return the full ldap path ... which i can feed to the next command..
|
|
Top
|
|
|
|
#129115 - 2004-11-08 05:19 PM
Re: How to find an OU?
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Unless your OU naming scheme is rock-solid consistent, I would suggest you stick with your original plan ... why not just create an INI file of all your OU's, and give them nicknames like you already have ...
[OU] HR = "OU=xyz,OU=XYZ2,OU=HR,DC=company,DC=loc" MTG = "OU=xyz,OU=XYZ2,OU=MTG,DC=company,DC=loc" ACC = "OU=xyz,OU=XYZ2,OU=ACC,DC=company,DC=loc"
I know this means a bit of maintenance going forward, but I get the feeling that if you just search on portions of the path, that it would be very slow plus you might run into ambiguity one day - I mean like if you had the name HR in two seperate branches, what then ?
-Shawn
|
|
Top
|
|
|
|
#129116 - 2004-11-08 05:21 PM
Re: How to find an OU?
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
damn! youīre really fast, hold up, I canīt type that fast!  If I get the OU with dsquery, I have to pipe it to a text file, to use it in my kixscript.. which I have to open & readline to do anything with it in kix.. or is there a way to put the dsquery output in a kix var? something like $var1=Shell "%COMSPEC% /C DSquery OU -name HR cause when I remember this correctly this will only put the exitcode of the shell command in $var1, not the output..
thanks btw..
|
|
Top
|
|
|
|
#129119 - 2004-11-08 07:44 PM
Re: How to find an OU?
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Well if you ask me, but you didn't...but I will say it anyway.
I would create a group in each OU that represents the OU. Globalgroup "SALES" in the OU=SALES,dc=dc1,dc=domain,dc=com Globalgroup "Engineering" in the OU=Engineering,dc=dc1,dc=domain,dc=com
1) use TranslateName() UDF to get the DN of the Group. 2) strip off the CN=SALES to get OU DN or bind to the Group object and get "$grp.Parent" 3) you can use TranslateName() to get the DN of the user and like in #2 you have the user's OU
I would explore a script that takes input like move user (user1) from group SALES to group Engineering. You then can implemet the above listed staep to get all the info you need.
|
|
Top
|
|
|
|
#129120 - 2004-11-09 11:14 AM
Re: How to find an OU?
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
Thanks guys, I really appreciate the fast responses. you all gave me some nice ideas to explore. in response to the ambiguity issue: All ou names in our org are unique, and this wil never change (at least not in the short-medium term) so that should not be an issue.
at this time I have 4 options, & thatīs all I need
1) the INI file (safe but high main.) 2) dsquery ->pipe to text file, open, readline etc. (slow, due to the piping of the file & opening it, but maybe the easiest to implement) (i need the path for other things so I canīt pipe it directly to DSMOVE for instance.) 3) the idea of the groups in OUīs is nice, but is also like 1 high main. 4) maybe the kixforms script includes some nice ideas, lookin in it now.
once again thanks guys..
ps: a lot has changed since kix 3.6x/NT4. It still is quite a culture shock..
ps ps: Iīm well known for my "nasty" (ugly code) kix scripts but if you guys would like I could post the completed code here once itīs ready..
|
|
Top
|
|
|
|
#129122 - 2004-11-09 01:59 PM
Re: How to find an OU?
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Quote:
2) dsquery ->pipe to text file, open, readline etc. (slow, due to the piping of the file & opening it, but maybe the easiest to implement) (i need the path for other things so I canīt pipe it directly to DSMOVE for instance.)
Specifically your comment "slow, due to the piping of the file & opening it," ... I would not dismiss this option on those grounds ... imagine that the piping and reading back in would be very fast. Think the "slow" bit might be in running the dsquery itself. But since I haven't tested it, can't say. dsquery might be very quick.
-Shawn
|
|
Top
|
|
|
|
#129125 - 2004-11-09 09:31 PM
Re: How to find an OU?
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Not sure why the Group suggestion would be high maintenance. The groups do not need to have any members unless you want them to for applying permissions to some file server. In this case your maintenance is the same since you have to maintain memberships anyway. The intent of the group was simply a place holder in the OU that you would know existed so that if the OU changed names or location you could still find it.
|
|
Top
|
|
|
|
#172537 - 2007-01-08 04:06 PM
Re: How to find an OU?
[Re: Arend_]
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
You might want to give fnLDAPQuery() a try then. This UDF was not published when this post was started.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1452 anonymous users online.
|
|
|