Sync Domain Control 
Author Message
 Sync Domain Control

I'll be glad to give your SyncDomain component a try.

Cyril Baratoff
XLnow



Tue, 24 Apr 2001 03:00:00 GMT  
 Sync Domain Control
Hello Ian

Any chance of a simple sample C procedure that synchrfonizes the BDC with
the PDC using the relevant APIs?

I can probably convert it into VB.

From Stuart Grace


    Sorry, We used C++.



Wed, 25 Apr 2001 03:00:00 GMT  
 Sync Domain Control
I found this on http://www.netfokus.dk/vbadmincode/ in the C++ section

// The following function gets the name of the primary

// domain controller and sends the message to synchronize all BDC's with the

// PDC.

void SynchronizeBDC(void)

{

wchar_t Domain[90];

wchar_t *PDC;

char Server[50];

PNETLOGON_INFO_1 pNet;

NET_API_STATUS status;

int length;

length =

MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,"THEDOMAINNAME",-1,Domain,90);

if (length == 0) {

// cout << "MultiToWideChar failed."<< endl;

return;

Quote:
}

status = NetGetDCName(NULL, Domain, (LPBYTE*)&PDC);

if (!status) {

length = WideCharToMultiByte(CP_ACP, 0, PDC, -1, (Server), 50, NULL,

NULL);

if (length == 0) {

// cout << "WideCharToMulti failed."<< endl;

return;

Quote:
}

// else cout << "Server = "<< Server << endl;

length =

MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,(Server+2),-1,Domain,90);

if (length == 0) {

// cout << "MultiToWideChar failed."<< endl;

return;

Quote:
}

status = I_NetLogonControl(Domain, NETLOGON_CONTROL_PDC_REPLICATE, 1,

(LPBYTE *)&pNet);

if (!status) {

// cout << "Passed replicate. "<< endl;

NetApiBufferFree(pNet);

Quote:
}

// else cout << "Failed replicate PDC. Error: "<< status << endl;

Quote:
}

else {

//cout << "Couldn't get Domain Controller name"<< endl;

return;

Quote:
}
}

>Hello Ian

>Any chance of a simple sample C procedure that synchrfonizes the BDC with
>the PDC using the relevant APIs?

>I can probably convert it into VB.

>From Stuart Grace


>    Sorry, We used C++.



Thu, 26 Apr 2001 03:00:00 GMT  
 Sync Domain Control
Thanks for the code Ian

That's just what I was looking for. With what's in the lmaccess.h file and
your example C++ code, I should be able to write a VB function to
Synchronize doamins.

From Stuart Grace


Quote:
>I found this on http://www.netfokus.dk/vbadmincode/ in the C++ section

>// The following function gets the name of the primary

>// domain controller and sends the message to synchronize all BDC's with
the

>// PDC.

>void SynchronizeBDC(void)

>{

>wchar_t Domain[90];

>wchar_t *PDC;

>char Server[50];

>PNETLOGON_INFO_1 pNet;

>NET_API_STATUS status;

>int length;

>length =

>MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,"THEDOMAINNAME",-1,Domain,90);

>if (length == 0) {

>// cout << "MultiToWideChar failed."<< endl;

>return;

>}

>status = NetGetDCName(NULL, Domain, (LPBYTE*)&PDC);

>if (!status) {

>length = WideCharToMultiByte(CP_ACP, 0, PDC, -1, (Server), 50, NULL,

>NULL);

>if (length == 0) {

>// cout << "WideCharToMulti failed."<< endl;

>return;

>}

>// else cout << "Server = "<< Server << endl;

>length =

>MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,(Server+2),-1,Domain,90);

>if (length == 0) {

>// cout << "MultiToWideChar failed."<< endl;

>return;

>}

>status = I_NetLogonControl(Domain, NETLOGON_CONTROL_PDC_REPLICATE, 1,

>(LPBYTE *)&pNet);

>if (!status) {

>// cout << "Passed replicate. "<< endl;

>NetApiBufferFree(pNet);

>}

>// else cout << "Failed replicate PDC. Error: "<< status << endl;

>}

>else {

>//cout << "Couldn't get Domain Controller name"<< endl;

>return;

>}

>}


>>Hello Ian

>>Any chance of a simple sample C procedure that synchrfonizes the BDC with
>>the PDC using the relevant APIs?

>>I can probably convert it into VB.

>>From Stuart Grace


>>    Sorry, We used C++.



Thu, 26 Apr 2001 03:00:00 GMT  
 Sync Domain Control
Hello Ian!

I have nearly finished converting the C program to VB

However, there is one line that i don't understand.

length = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,(Server+2),-1,Domain,90)

I asume this function returns Domain which is used in the Domain setting for
the
I_NetLogonControl API

What I don't understand is the (Server+2) part. I assume that Server is the
PDC Name. What exactly is a "WideChar"?

(My VB function runs but returns an error code of 124. havn't a clue what
this means!)

Any ideas would be appreciated!

From Stuart

Quote:
>I found this on http://www.netfokus.dk/vbadmincode/ in the C++ section

>// The following function gets the name of the primary

>// domain controller and sends the message to synchronize all BDC's with
the

>// PDC.

>void SynchronizeBDC(void)

>{

>wchar_t Domain[90];

>wchar_t *PDC;

>char Server[50];

>PNETLOGON_INFO_1 pNet;

>NET_API_STATUS status;

>int length;

>length =

>MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,"THEDOMAINNAME",-1,Domain,90);

>if (length == 0) {

>// cout << "MultiToWideChar failed."<< endl;

>return;

>}

>status = NetGetDCName(NULL, Domain, (LPBYTE*)&PDC);

>if (!status) {

>length = WideCharToMultiByte(CP_ACP, 0, PDC, -1, (Server), 50, NULL,

>NULL);

>if (length == 0) {

>// cout << "WideCharToMulti failed."<< endl;

>return;

>}

>// else cout << "Server = "<< Server << endl;

>length =

>MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,(Server+2),-1,Domain,90);

>if (length == 0) {

>// cout << "MultiToWideChar failed."<< endl;

>return;

>}

>status = I_NetLogonControl(Domain, NETLOGON_CONTROL_PDC_REPLICATE, 1,

>(LPBYTE *)&pNet);

>if (!status) {

>// cout << "Passed replicate. "<< endl;

>NetApiBufferFree(pNet);

>}

>// else cout << "Failed replicate PDC. Error: "<< status << endl;

>}

>else {

>//cout << "Couldn't get Domain Controller name"<< endl;

>return;

>}

>}


>>Hello Ian

>>Any chance of a simple sample C procedure that synchrfonizes the BDC with
>>the PDC using the relevant APIs?

>>I can probably convert it into VB.

>>From Stuart Grace


>>    Sorry, We used C++.



Sat, 28 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Time Sync with my WInNT Domain

2. New version of Domain Sync DLL

3. How do I initiate a Domain Sync remotely?

4. finding all domains under the root domain

5. Getting domain name of parent domain

6. authentication problems from domain to domain

7. How to List Domain Controllers in domain

8. finding all domains under the root domain

9. time sync

10. Sync/blocking call posible with JSRS?

11. Sync data between JS vars and Text Fields

12. 2-way browser sync

 

 
Powered by phpBB® Forum Software