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.

138 lines
3.0 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Active Directory 1.0 Sample Code
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996
  6. //
  7. // File: main.cxx
  8. //
  9. // Contents: Main for adscmd
  10. //
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "main.hxx"
  14. GUID sapguid;
  15. #define ssgData1 0xa5569b20
  16. #define ssgData2 0xabe5
  17. #define ssgData3 0x11ce
  18. #define ssgData41 0x9c
  19. #define ssgData42 0xa4
  20. #define ssgData43 0x00
  21. #define ssgData44 0x00
  22. #define ssgData45 0x4c
  23. #define ssgData46 0x75
  24. #define ssgData47 0x27
  25. #define ssgData48 0x31
  26. //-------------------------------------------------------------------------
  27. //
  28. // main
  29. //
  30. //-------------------------------------------------------------------------
  31. void __cdecl
  32. main()
  33. {
  34. IADsContainer *pContainer = NULL;
  35. IADs *pObj = NULL;
  36. IDispatch *pDispatch = NULL;
  37. IADsService *pService = NULL;
  38. BSTR bstrName;
  39. HRESULT hr;
  40. LPWSTR lpwstrPath = NULL;
  41. LPWSTR lpwstrService, lpwstrRelName;
  42. hr = CoInitialize(NULL);
  43. if (FAILED(hr)) {
  44. printf("CoInitialize failed\n");
  45. exit(1);
  46. }
  47. char buffer[500];
  48. scanf("%s", buffer);
  49. // lpwstrPath = AllocateUnicodeString("WinNT://SEANW1");
  50. printf("%s", buffer);
  51. lpwstrPath = AllocateUnicodeString(buffer);
  52. lpwstrService = AllocateUnicodeString("user");
  53. lpwstrRelName = AllocateUnicodeString("IISfoo");
  54. BAIL_ON_NULL(lpwstrPath);
  55. BAIL_ON_NULL(lpwstrService);
  56. BAIL_ON_NULL(lpwstrRelName);
  57. hr = ADsGetObject(
  58. lpwstrPath,
  59. IID_IADsContainer,
  60. (void**) &pContainer);
  61. BAIL_ON_FAILURE(hr);
  62. // Create a services object
  63. hr = pContainer->Create(lpwstrService, lpwstrRelName, &pDispatch);
  64. if (FAILED(hr)) {
  65. printf("Create failed\n");
  66. goto error;
  67. }
  68. IADsUser *pUser;
  69. pDispatch->QueryInterface(IID_IADs, (void**)&pObj);
  70. pDispatch->QueryInterface(IID_IADsUser, (void**)&pUser);
  71. // pDispatch->QueryInterface(IID_IADsService, (void**)&pService);
  72. // Get services obj
  73. // pObj->QueryInterface(IID_IADsService, (void**) &pService);
  74. /*
  75. // fill in params
  76. VARIANT var;
  77. VariantInit(&var);
  78. var.vt = VT_BSTR;
  79. var.bstrVal = SysAllocString(L"0xa5569b20abe511ce9ca400004c752731");
  80. BSTR name;
  81. name = SysAllocString(L"serviceClassID");
  82. hr = pObj->Put(name, var);
  83. if (FAILED(hr)) {
  84. printf("Put failed");
  85. goto error;
  86. }
  87. */
  88. hr = pUser->SetInfo();
  89. if (FAILED(hr)) {
  90. printf("SetInfo failed");
  91. goto error;
  92. }
  93. pContainer->Release();
  94. pObj->Release();
  95. pService->Release();
  96. printf("No Error\n");
  97. FreeUnicodeString(lpwstrPath);
  98. FreeUnicodeString(lpwstrRelName);
  99. FreeUnicodeString(lpwstrService);
  100. return;
  101. error:
  102. printf("Error:\t%d\n", hr);
  103. FreeUnicodeString(lpwstrPath);
  104. FreeUnicodeString(lpwstrRelName);
  105. FreeUnicodeString(lpwstrService);
  106. }