Leaked source code of windows server 2003
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.

130 lines
3.3 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <stddef.h>
  8. #include <shellapi.h>
  9. #include "dfsheader.h"
  10. #include "dfsmisc.h"
  11. #include "dfsprefix.h"
  12. #include "..\..\lib\dfsgram\dfsobjectdef.h"
  13. #include "DfsAdmin.h"
  14. DFSSTATUS
  15. DfsView (
  16. LPWSTR RootName,
  17. FILE *Out )
  18. {
  19. LPBYTE pBuffer = NULL;
  20. DWORD ResumeHandle = 0;
  21. DWORD EntriesRead = 0;
  22. DWORD PrefMaxLen = -1;
  23. DWORD Level = 4;
  24. DFSSTATUS Status;
  25. PDFS_INFO_4 pCurrentBuffer;
  26. DWORD i;
  27. if (DebugOut)
  28. {
  29. fwprintf(DebugOut, L"Contacting %wS for enumeration \n", RootName);
  30. }
  31. Status = NetDfsEnum( RootName,
  32. Level,
  33. PrefMaxLen,
  34. &pBuffer,
  35. &EntriesRead,
  36. &ResumeHandle);
  37. if (DebugOut)
  38. {
  39. fwprintf(DebugOut, L"Enumeration for %wS is complete %d entries\n",
  40. RootName,
  41. EntriesRead);
  42. }
  43. if (Status != ERROR_SUCCESS)
  44. {
  45. printf("Export: cannot enum %wS: error %x\n", RootName, Status);
  46. }
  47. else {
  48. pCurrentBuffer = (PDFS_INFO_4)pBuffer;
  49. for (i = 0; i < EntriesRead; i++)
  50. {
  51. DumpDfsInfo(i, Level, pCurrentBuffer, Out);
  52. pCurrentBuffer++;
  53. }
  54. fwprintf(Out, L"END ROOT\n");
  55. }
  56. return Status;
  57. }
  58. DumpDfsInfo(
  59. DWORD Entry,
  60. DWORD Level,
  61. PDFS_INFO_4 pBuf,
  62. FILE *Out)
  63. {
  64. DWORD i;
  65. PDFS_STORAGE_INFO pStorage;
  66. UNICODE_STRING LinkName, ServerName, ShareName, Remains;
  67. DFSSTATUS Status;
  68. if (Level != 4) {
  69. printf("Fix Dump DfsInfo for different levels\n");
  70. return 0;
  71. }
  72. if (Entry == 0)
  73. {
  74. fwprintf(Out, L"ROOT %ws \n", pBuf->EntryPath);
  75. for(i = 0, pStorage = pBuf->Storage;
  76. i < pBuf->NumberOfStorages;
  77. i++, pStorage = pBuf->Storage+i)
  78. {
  79. fwprintf(Out, L"\tTARGET \\\\%ws\\%ws\n",
  80. pStorage->ServerName, pStorage->ShareName);
  81. }
  82. fwprintf(Out, L"\n");
  83. }
  84. else
  85. {
  86. RtlInitUnicodeString( &LinkName, pBuf->EntryPath);
  87. Status = DfsGetPathComponents(&LinkName,
  88. &ServerName,
  89. &ShareName,
  90. &Remains);
  91. fwprintf(Out, L"\tLINK \"%ws\" ", Remains.Buffer);
  92. if (pBuf->Comment && (pBuf->Comment[0] != 0))
  93. {
  94. printf("Comment is %ws\n", pBuf->Comment);
  95. fwprintf(Out, L"\tCOMMENT \"%ws\" ", pBuf->Comment);
  96. }
  97. fwprintf(Out, L"\tSTATE %x ", pBuf->State);
  98. if (pBuf->Timeout != 0)
  99. {
  100. fwprintf(Out, L"\tTIMEOUT %d ", pBuf->Timeout);
  101. }
  102. fwprintf(Out, L"\n");
  103. for(i = 0, pStorage = pBuf->Storage;
  104. i < pBuf->NumberOfStorages;
  105. i++, pStorage = pBuf->Storage+i)
  106. {
  107. fwprintf(Out, L"\t\tTARGET \\\\%ws\\%ws",
  108. pStorage->ServerName, pStorage->ShareName);
  109. fwprintf(Out, L"\tSTATE %x \n", pStorage->State);
  110. }
  111. }
  112. fwprintf(Out, L"\n");
  113. return 0;
  114. }