Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu konu, etki alanındaki bir nesneyi taşımak için kullanılan kod örneklerini içerir.
Aşağıdaki C++ kod örneği, etki alanındaki bir nesneyi taşımak için ADSI'nin nasıl kullanılacağını gösterir.
#include <stdio.h>
#include <atlbase.h>
#include <activeds.h>
#include <ntldap.h>
/***************************************************************************
MoveObject()
Moves an object in the directory.
Parameters:
padsToMove - Contains an IADs interface pointer that represents the
object to move.
padsDestination - Contains an IADs interface pointer that represents the
container to move the object to.
***************************************************************************/
HRESULT MoveObject(IADs *padsToMove, IADs *padsDestination)
{
_ASSERT(padsToMove);
_ASSERT(padsDestination);
HRESULT hr;
// Get the ADsPath of the object to move.
CComBSTR sbstrPathToMove;
hr = padsToMove->get_ADsPath(&sbstrPathToMove);
if(FAILED(hr))
{
return hr;
}
// Get an IADsContainer instance from the destination.
CComPtr<IADsContainer> spContainerDestination;
hr = padsDestination->QueryInterface(IID_IADsContainer, (void**)&spContainerDestination);
if(FAILED(hr))
{
return hr;
}
// Move the object.
CComPtr<IDispatch> spDispNewObject;
hr = spContainerDestination->MoveHere(sbstrPathToMove, NULL, &spDispNewObject);
return hr;
}
Aşağıdaki Visual Basic kod örneği, etki alanındaki bir nesneyi taşımak için ADSI'nin nasıl kullanılacağını gösterir.
''''''''''''''''''''''''''''''''''''''''
'
' MoveObject
'
' Moves an object in the directory.
'
' Parameters:
'
' DNToMove - Contains the distinguished name of the object to move.
'
' DNDestination - Contains the distinguished name of the destination
' container.
'
''''''''''''''''''''''''''''''''''''''''
Public Sub MoveObject(DNToMove As String, DNDestination As String)
Dim oContainer As IADsContainer
' Bind to the destination container.
Set oContainer = GetObject("LDAP://" & DNDestination)
oContainer.MoveHere "LDAP://" & DNToMove, vbNullString
End Sub