Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.6 KiB

  1. #include "main.hxx"
  2. void main()
  3. {
  4. IADsContainer *pRootContainer;
  5. IADs *pGlobal;
  6. IDispatch *pDispatchNewObject;
  7. IADs *pNewObject;
  8. HRESULT hr;
  9. CoInitialize(NULL);
  10. //
  11. // Bind to the known container.
  12. //
  13. hr = ADsGetObject(TEXT("LDAP://RootDSE"),
  14. IID_IADs,
  15. (void**)&pGlobal);
  16. if (FAILED(hr)) {
  17. printf("GetObject failed, hr = %X\n", hr);
  18. return;
  19. } else {
  20. printf("Get Object Succeeded\n");
  21. }
  22. VARIANT varRootPath;
  23. hr = pGlobal->Get(L"defaultNamingContext", &varRootPath);
  24. if (FAILED(hr)) {
  25. printf("Get Root Path failed, hr = %X\n", hr);
  26. return;
  27. }
  28. WCHAR pszRootPath[500];
  29. wcscpy(pszRootPath, L"LDAP://");
  30. wcscat(pszRootPath, varRootPath.bstrVal);
  31. hr = ADsGetObject(pszRootPath,
  32. IID_IADsContainer,
  33. (void**)&pRootContainer);
  34. if (FAILED(hr)) {
  35. printf("Get Root Container Object failed, hr = %X\n", hr);
  36. return;
  37. }
  38. hr = pRootContainer->Create(L"IISServiceLocation", L"cn=TestName", &pDispatchNewObject);
  39. if (FAILED(hr)) {
  40. printf("Create new Object failed, hr = %X\n", hr);
  41. return;
  42. }
  43. //
  44. // Get IADs Interface From Container
  45. //
  46. hr = pDispatchNewObject->QueryInterface(IID_IADs, (void**)&pNewObject);
  47. if (FAILED(hr)) {
  48. printf("QI NewClass failed, hr = %X\n", hr);
  49. return;
  50. }
  51. hr = pNewObject->SetInfo();
  52. if (FAILED(hr)) {
  53. printf("SetInfo failed, hr = %X\n", hr);
  54. }
  55. CoUninitialize();
  56. }