通过 IADS 删除 Active Directory 中的对象
这是 MSDN 中用于删除对象(例如 user 、...)的示例代码 但是当我使用这个例子时
这一行“pOps->DeleteObject(0);”结果是“E_ACCESSDENIED”为什么? 你能帮我吗
IADsContainer *pCont;
LPWSTR adsPath = L"LDAP://OU=Sales,DC=Fabrikam,DC=com";
HRESULT hr = ADsGetObject(adsPath,IID_IADsContainer,(void**)&pCont);
if (FAILED(hr)) exit(hr);
IADsDeleteOps *pOps;
hr = pCont->QueryInterface(IID_IADsDeleteOps,(void**)&pOps);
pCont->Release();
if(FAILED(hr) exit(hr);
pOps->DeleteObject(0);
pOps-Release();
this is a sample code in MSDN for deleting an object such as user , ...
but when i am using this example
this line "pOps->DeleteObject(0);" result is "E_ACCESSDENIED" why ?
would you please help me
IADsContainer *pCont;
LPWSTR adsPath = L"LDAP://OU=Sales,DC=Fabrikam,DC=com";
HRESULT hr = ADsGetObject(adsPath,IID_IADsContainer,(void**)&pCont);
if (FAILED(hr)) exit(hr);
IADsDeleteOps *pOps;
hr = pCont->QueryInterface(IID_IADsDeleteOps,(void**)&pOps);
pCont->Release();
if(FAILED(hr) exit(hr);
pOps->DeleteObject(0);
pOps-Release();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您用于执行操作的帐户没有删除目标对象的权限。
The account you are using to perform the action does not have permission to delete the target object.
使用 ADsOpenObject,它将用户名和密码作为参数传递管理员凭据,代码将正常工作。
供参考链接
Use the ADsOpenObject which takes username and password as arguments pass the administrator credentials and the code will work fine.
For reference Link