????? ????? ???? Exchange ??????? ?????? ???? ????????

?????? ????????? ?????? ?????????
???? ???????: 261229 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

??????

??? ??????? ????? ????? ?????? Exchange Microsoft ? ??? ????? ???? ??????? ?????? ???? ????????. ?????? ?????? ????? Exchange ????????? ????? ???? Windows ??????? ?????? ??? ???? ???? ??? ???? ??????. ??? ????? ?? ????? ????? ????????? (API) ?????? ??? ????? ?????? ??????? ?? ????? ???? ????? Microsoft (MSDN) Win32 API. ??? ???? ?????? ???????? ?? ??? ????? Exchange ?? DS_SERVICE_CONTROL_RECALC_HIERARCHY. ?? ???? ??? ?????? 129.

???? ??? ?????? ????? ????? ????? ?????? ?????? ?????? ?? ??????? ?????? ???? ????????. ????? ????? ?? ????? ???? ??????? ?????? ???? ???????? ?? ????? ?? ??? ????? ?? ?????? ????? Exchange ??? ??? ????? ???????? ????????. ????? ??? ????? ???? ???? ??????? ????? (?????? ????? ??? F5) ?? ?????? ????? Exchange.

??????? ????

??????? ????? Microsoft Visual Basic ? Microsoft Visual C++ ??????? ????? ????? ?????? Active Directory (ADSI) ?????? ????? ?????? ???? ????? ?? ?????? Exchange Server Win32 API ?????? ???? ???? ??? ???? ???? Exchange ??? ????? ???? ?? ??????? ?????? ???? ????????.

????? Visual Basic

'Add a reference to ActiveDS Type library.
'Search for TODO in the following code to set configuration 
'information.
'
Private Type SERVICE_STATUS
  dwServiceType As Long
  dwCurrentState As Long
  dwControlsAccepted As Long
  dwWin32ExitCode As Long
  dwServiceSpecificExitCode As Long
  dwCheckPoint As Long
  dwWaitHint As Long
End Type

Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const SC_MANAGER_CONNECT = &H1
Private Const SC_MANAGER_CREATE_SERVICE = &H2
Private Const SC_MANAGER_ENUMERATE_SERVICE = &H4
Private Const SC_MANAGER_LOCK = &H8
Private Const SC_MANAGER_MODIFY_BOOT_CONFIG = &H20
Private Const SC_MANAGER_QUERY_LOCK_STATUS = &H10
Private Const SC_MANAGER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _
SC_MANAGER_CONNECT Or SC_MANAGER_CREATE_SERVICE Or _
SC_MANAGER_ENUMERATE_SERVICE Or SC_MANAGER_LOCK Or _
SC_MANAGER_QUERY_LOCK_STATUS Or SC_MANAGER_MODIFY_BOOT_CONFIG)
Private Const SERVICE_USER_DEFINED_CONTROL = &H100

Private Declare Function CloseServiceHandle Lib _
    "advapi32.dll" (ByVal hSCObject As Long) As Long
Private Declare Function OpenSCManager Lib _
    "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As _
    String, ByVal dwDesiredAccess As Long) As Long
Private Declare Function OpenService Lib "advapi32.dll" Alias      "OpenServiceA" (ByVal hSCManager As Long, ByVal lpServiceName As       String, ByVal dwDesiredAccess As Long) As Long
Private Declare Function ControlService Lib "advapi32.dll" _
    (ByVal hService As Long, ByVal dwControl As Long, lpServiceStatus      As SERVICE_STATUS) As Long

        
Private Sub Main()
Dim objExistingCont As IADsContainer
Dim objNewCont As IADs
Dim sstStatus As SERVICE_STATUS
Dim hSCM As Long
Dim hService As Long

' Bind to an existing container.

//TODO : Change the ADsPath to reflect your Exchange Organization.
Set objExistingCont =       GetObject("LDAP://MyExchServer/ou=MySite,o=MyOrg")
' Make a new container<BR/>

//TODO: Set the new container directory name.
Set objNewCont = objExistingCont.Create("Container","cn=MyNewCont")
' Put the continer-info prop to tell Exchange this is a recipients cont.
objNewCont.Put "Container-Info", &H80000001

//TODO: Change the next line to set the Display name.
objNewCont.Put "Admin-Display-Name", "MyNewCont"
objNewCont.SetInfo
Set objCont = Nothing
Set objNewCR = Nothing<BR/>

'Now recalculate the address book hierarchy.

//TODO: change first paramater to the name of the Exchange server.
hSCM = OpenSCManager("\\MyExchServer", vbNullString, SC_MANAGER_ALL_ACCESS)
hService = OpenService(hSCM, "MSExchangeDS", SERVICE_USER_DEFINED_CONTROL)
lret = ControlService(hService, 129, sstStatus)
lret = CloseServiceHandle(hService)
lret = CloseServiceHandle(hSCM)
End Sub
				

????? C++ ???????

//Link with activeds.lib and adsiid.lib.
//Search for TODO in the following code to set configuration 
//information.
// 
#include "activeds.h"
#include "Windows.h"
#define DS_SERVICE_CONTROL_RECALC_HIERARCHY	0x081
#define contType 0x80000001

int main(int argc, char* argv[])
{


HRESULT			hr		=	S_OK;                
IADsContainer	*pCont;
IDispatch		*pDisp	=	NULL;
IDispatch		*pDisp2	=	NULL;
IADs			*pNewCont;
VARIANT			var;
LPOLESTR szAttributeToSet = NULL;
SC_HANDLE		schSCManager,schService;
SERVICE_STATUS	ssStatus; 
//TODO: set this to the name of the Exchange server.
LPSTR			pmachine = "\\\\MyExchangeServer";



// You must initialize COM before calling any ADSI functions or interfaces.
CoInitialize(NULL);
//TODO : Change the ADsPath to reflect your Exchange Organization.
hr = ADsGetObject(L"LDAP://MyExchServer/ou=Mysite,o=MyOrg",
IID_IADsContainer, (void**) &pCont );
   
if ( !SUCCEEDED(hr) )
{
       return 0;
}
//TODO: Set the new container directory name.
hr = pCont->Create( L"container", L"cn=MyNewContainer", &pDisp );        

// Now Query Interface for IADs.
hr = pDisp->QueryInterface( IID_IADs, (void**) &pNewCont);
pDisp->Release();         

//Add Container-Info property to tell Exchange it is a recipients container.

szAttributeToSet = L"Container-Info";
        var.vt = VT_I4;
        var.lVal = contType;
        hr = pNewCont->Put(szAttributeToSet,var);
        VariantClear(&var);

//Add Admin-Display-Name property.
szAttributeToSet = L"Admin-Display-Name";
	var.vt = VT_BSTR;
//TODO: Change the next line to set the Display name
	var.bstrVal = SysAllocString(L"MyNewContainer");
	hr = pNewCont->Put(szAttributeToSet,var);
	VariantClear(&var);

// Now "commit" the Container Creation.
hr = pNewCont -> SetInfo();

pNewCont->Release();
pCont->Release();
CoUninitialize();


// Open a handle to the SC Manager database. 
 
schSCManager = OpenSCManager( 
    pmachine,                // Exchange server 
    NULL,                    // ServicesActive database 
    SC_MANAGER_ALL_ACCESS);  // full access rights 
 
if (schSCManager != NULL) 
{
	// Open a handle to the service. 
    schService = OpenService( 
        schSCManager,       // SCManager database 
        "MSExchangeDS",       // name of service 
        SERVICE_USER_DEFINED_CONTROL);             
 
    if (schService != NULL)  
	// Send a control value to the service. 
		ControlService( 
            schService,   // handle of service 
            DS_SERVICE_CONTROL_RECALC_HIERARCHY,   // control value to send 
            &ssStatus);  // address of status info
}

//cleanup:
if (schSCManager)
	CloseServiceHandle(schSCManager);
if (schService)
	CloseServiceHandle(schService);

return (hr);        

}
				

?????

?????? ??? ??????? ??????? ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
171723????? ????? ??? ADSI ?? Visual C++

???????

???? ???????: 261229 - ????? ??? ??????: 03/???? ??????/1435 - ??????: 4.1
????? ???
  • Microsoft Active Directory Service Interfaces 2.5
  • Microsoft Exchange Server 5.5 Standard Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbhowto kbmsg KB261229 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????261229

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com