Page 1 of 1 1
Topic Options
#72148 - 2002-12-08 03:09 PM LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi Everyone

I have made this script up with help from this board, that reads a excel file and then builds users into AD.

This works fine, but I have 2 domain controllers, and when the script runs, it builds the users on the active PDC and then you have to wait 5-10 minutes until Microsoft replicates the 2 domain controllers.

code:
  
$adsDomain = GetObject("LDAP://OU=Users,OU=QEH Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk")

That is the line I am using, but can I specify a domain controller, and then what I could do is run the line twice using the DC1, then DC2.

The reason I need to do this is because I also create the home folders for the users and set permissions using CACLS, but when I run CACLS it says user does not exist.

Please help.

Thank You.

Richard

Top
#72149 - 2002-12-08 03:13 PM Re: LDAP Connection into AD
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm...
in my user script I use simply:
shell "net accounts /sync /domain"
_________________________
!

download KiXnet

Top
#72150 - 2002-12-08 03:24 PM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks for the quick return, but I get this error message, I will find out why.

code:
C:\Documents and Settings\administrator.QEH-TR>net accounts /sync /domain
You used an option with an invalid value.

More help is available by typing NET HELPMSG 3505.

Richard

Top
#72151 - 2002-12-08 03:28 PM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
I am using Windows 2000, in the help it says it should work.
Top
#72152 - 2002-12-08 03:38 PM Re: LDAP Connection into AD
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can direct the ADSI action to individual servers, but you can not duplicate the same account creation on both servers as you will get two different accounts that will collide and result in the replacement of one with the other. In AD the last write wins during domain replication.

If you know that the home directory for user1 is on server2 then you can create the account on server2 with the home directory and let it replicate back to server1. If the home directory for user2 will exist on server1 then create the account there and let it replicate to server2.

You can use the LDAP format that specifies the target container like:
code:
"LDAP://$server/$ADS_NAME_TYPE_1779"

$adsObject = GetObject("LDAP://" + $server + "/OU=Users,OU=QEH Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk")



[ 08. December 2002, 15:39: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72153 - 2002-12-08 03:51 PM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
You are a Diamond.

Thank You very much.

Top
#72154 - 2002-12-08 03:58 PM Re: LDAP Connection into AD
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
richard, the domain was too much.
simple /sync does it.
_________________________
!

download KiXnet

Top
#72155 - 2002-12-08 04:00 PM Re: LDAP Connection into AD
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A simple
code:
net /?

or
code:
net accounts /?

would help, too, (pun intended), to figure out what was wrong with that line.

[ 08. December 2002, 16:01: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#72156 - 2002-12-09 12:22 AM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
OK

net accounts /sync with or without the /domain does not work.

I have tried it and I get a error.

So if anyone has any other way of replication the AD then please tell me.

Richard

Top
#72157 - 2002-12-09 12:23 AM Re: LDAP Connection into AD
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
richard ???

what the error is if you try it on commandline?
_________________________
!

download KiXnet

Top
#72158 - 2002-12-09 12:24 AM Re: LDAP Connection into AD
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Still wondering why you want to force a replication. Are your home directories on a server other than on the domain controller? Could you provide more details of your architecture?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72159 - 2002-12-09 12:34 AM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
2 X Domain Controllers

My script reads a excel file and creates users into AD. That works fine.

Now when using this script it puts in the Home folder properties into the User account, but it does not create the physical folder (this is not located on the DC's).

So I have added at the bottom of my 1st script that creates the users, to create the home folder. This works as well.

Now when I go to change permissions on these folders, the CACLS command comes back with a error saying that the user has not been built, because the users that are being built have not been replicated to the other Domain Controller.

So I have 2 choices, run the Create user script. wait for 15 minutes until the DC's have replicated and then run the Folder creation and permissions script.

or I can force a Domain Sync and run the Folder Creation script in the 1st script.

Does that make sence.

I do not have my script with me here so I will post it tomorrow.

Richard Farthing

Top
#72160 - 2002-12-09 12:47 AM Re: LDAP Connection into AD
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well, I assume that the server where the home directory exist is in a known site and that you can specify the DC. If you use the code I gave you above, then your could create the account on the DC that services the site where the home directory server is. If you create the account on the remote DC then XCALCS should find the exisiting account. Have tried that?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72161 - 2002-12-09 12:52 AM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
I have 2 Domain Controller called
dcserve1 & dcserve2.

Now I have a clustered File&Print Server, this services the users Shared data and the Users Home Folders.

Called

\\FPU\Users for the Users Home Data

and

\\FPS\Shared for the users shared data

So in the User properties for the Home folder I have.

\\FPU\Users\%UserName%\My Documents.

Now when using CACLS, how do I know what server it will look for to check if the Users are built. Will with allways be the active PDC. ???.

Richard Farthing

Top
#72162 - 2002-12-09 01:01 AM Re: LDAP Connection into AD
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
First question: is the clustered File&Print Server a W2K server in the AD architecture? If it is, the DC selected to service the secure channel connection will be the DC in the same SITE (assuming you have configured W2K sites).

Have you ever use NLTEST.exe? It will show you which DC it is using for authenticating accounts.

Are your DCs in separate sites?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72163 - 2002-12-09 01:22 AM Re: LDAP Connection into AD
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If you want to know the server name of the AD DC to which your file/print cluster is currently connected, I can add a method to Win32Admin that will return that information.

Then your script could create the home directory first, query the trust to get the server name of the AD DC, create the account on that server, and follow-up with XCALCS which should be using the same DC where the accounts were created.

[ 09. December 2002, 12:40: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72164 - 2002-12-09 10:42 AM Re: LDAP Connection into AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks, but I have sorted it now.

Once again Thanks for the responce, It's like you guys never sleep :-)

Richard Farthing

Top
#72165 - 2002-12-09 10:43 AM Re: LDAP Connection into AD
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
richard, mind sharing your solution?

btw, we doesn't sleep.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (StuTheCoder) and 798 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org