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.

151 lines
3.0 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996
  5. //
  6. // File: session.cxx
  7. //
  8. // Contents: Active Directory Session manipulation
  9. //
  10. // History: 05-07-96 RamV Created
  11. // 08-05-96 t-danal Add to oledscmd
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "main.hxx"
  15. #include "macro.hxx"
  16. #include "sconv.hxx"
  17. //
  18. // Dispatch Table Defs
  19. //
  20. #include "dispdef.hxx"
  21. DEFEXEC(ExecSessionDel);
  22. DEFDISPTABLE(DispTable) = {
  23. {"del", NULL, ExecSessionDel}
  24. };
  25. DEFDISPSIZE(nDispTable, DispTable);
  26. //
  27. // Local functions
  28. //
  29. HRESULT
  30. DeleteSession(
  31. LPWSTR szParentContainer,
  32. LPWSTR szSessionName
  33. );
  34. //
  35. // Local function definitions
  36. //
  37. HRESULT
  38. DeleteSession(
  39. LPWSTR szParentContainer,
  40. LPWSTR szSessionName
  41. )
  42. {
  43. HRESULT hr;
  44. IADsFileServiceOperations * pADsParent = NULL;
  45. IUnknown * pUnknown = NULL;
  46. IADs * pADs = NULL;
  47. IADsCollection *pCollection = NULL;
  48. hr = ADsGetObject(
  49. szParentContainer,
  50. IID_IADsFileServiceOperations,
  51. (void **)&pADsParent
  52. );
  53. BAIL_ON_FAILURE(hr);
  54. hr = pADsParent->Sessions(&pCollection);
  55. BAIL_ON_FAILURE(hr);
  56. hr = pCollection->Remove(szSessionName);
  57. BAIL_ON_FAILURE(hr);
  58. error:
  59. if (pADsParent) {
  60. pADsParent->Release();
  61. }
  62. if (pCollection) {
  63. pCollection->Release();
  64. }
  65. return(hr);
  66. }
  67. //
  68. // Exec function definitions
  69. //
  70. int
  71. ExecSession(char *szProgName, char *szAction, int argc, char * argv[])
  72. {
  73. if (!argc) {
  74. PrintUsage(szProgName, szAction, DispTable, nDispTable);
  75. return(1);
  76. }
  77. char *szPrevActions = szAction;
  78. szAction = argv[0];
  79. argc--;
  80. argv++;
  81. if (DoHelp(szProgName,
  82. szPrevActions, szAction, NULL,
  83. DispTable, nDispTable,
  84. NULL))
  85. return 0;
  86. return DispatchExec(DispTable, nDispTable,
  87. szProgName,
  88. szPrevActions, szAction,
  89. argc, argv);
  90. }
  91. int
  92. ExecSessionDel(
  93. char *szProgName,
  94. char *szAction,
  95. int argc,
  96. char * argv[]
  97. )
  98. {
  99. HRESULT hr;
  100. LPWSTR szParentContainer = NULL;
  101. LPWSTR szSessionName = NULL;
  102. if (argc != 2) {
  103. PrintUsage(szProgName,
  104. szAction,
  105. "<Container> <SessionName>");
  106. return(1);
  107. }
  108. szParentContainer = AllocateUnicodeString(
  109. argv[0]
  110. );
  111. szSessionName = AllocateUnicodeString(
  112. argv[1]
  113. );
  114. hr = DeleteSession(
  115. szParentContainer,
  116. szSessionName
  117. );
  118. FreeUnicodeString(szSessionName);
  119. FreeUnicodeString(szParentContainer);
  120. if (FAILED(hr)) {
  121. printf("DeleteSession failed with error code %x\n", hr);
  122. return(1);
  123. }
  124. return(0);
  125. }