IADsPathname 인터페이스
IADsPathname 인터페이스는 ADsPath의 다양한 요소를 구문 분석하고 수정합니다. 또한 다양한 표시 형식 간에 ADsPath를 변환합니다.
다음 코드 예제에서는 유지 관리 유틸리티에서 사용자에게 표시할 유효한 ADsPath에서 서버 이름을 추출하고 반환합니다.
HRESULT GetServerName(BSTR adsPath, BSTR *adsServer)
{
HRESULT hr = S_OK;
IADsPathname *pIADsPathname = NULL;
// Create the IADsPathname object.
hr = CoCreateInstance(CLSID_Pathname,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsPathname,
(void**) &pIADsPathname);
if (FAILED(hr))
{
if (pIADsPathname)
pIADsPathname->Release();
return (hr);
}
// Set the path.
hr = pIADsPathname->Set(adsPath, ADS_SETTYPE_FULL);
if (SUCCEEDED(hr))
// Extract and return the server name.
hr = pIADsPathname->Retrieve(ADS_FORMAT_SERVER, adsServer);
// Cleanup.
pIADsPathname->Release();
return (hr);
}
다음 코드 예제에서는 개체의 Distinguished Name 속성을 자체 ADsPath에서 설정하여 새로 만든 ADSI 개체를 초기화하는 데 도움이 됩니다. 호출 루틴은 SetInfo 메서드를 호출하여 기본 디렉터리 저장소에 대한 변경 내용을 커밋해야 합니다.
HRESULT SetDistinguishedName(IADs *pIADs)
{
HRESULT hr = S_OK;
CComBSTR sbstrADsPath;
IADsPathname *pIADsPathname = NULL;
// Get the ADsPath for this object.
hr = pIADs->get_ADsPath(&sbstrADsPath);
if (FAILED(hr))
return (hr);
// Create the IADsPathname object.
hr = CoCreateInstance(CLSID_Pathname,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsPathname,
(void**) &pIADsPathname);
if (FAILED(hr))
{
if (pIADsPathname)
pIADsPathname->Release();
return (hr);
}
// Set the path.
hr = pIADsPathname->Set(sbstrADsPath, ADS_SETTYPE_FULL);
if (SUCCEEDED(hr))
{
CComBSTR sbstrDNPath;
// Convert the path to Distinguished Name format.
hr = pIADsPathname->Retrieve(ADS_FORMAT_WINDOWS_DN,
&sbstrDNPath);
if (SUCCEEDED(hr))
{
// Set the distinguished name property.
VARIANT var;
VariantInit(&var);
V_BSTR(&var) = sbstrDNPath;
V_VT(&var) = VT_BSTR;
hr = pIADs->Put(CComBSTR("distinguishedName"), var);
VariantClear(&var);
}
}
// Cleanup.
pIADsPathname->Release();
return (hr);
}
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기