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.

151 lines
2.9 KiB

  1. //
  2. // Copyright (C) 2000-2002, Microsoft Corporation
  3. //
  4. // File: DomInfo.c
  5. //
  6. // Contents: miscellaneous dfs functions.
  7. //
  8. // History: Dec. 8 2000, Author: udayh
  9. //
  10. //-----------------------------------------------------------------------------
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <malloc.h>
  18. #include <dsgetdc.h>
  19. #include <lm.h>
  20. #include <dfsheader.h>
  21. #include <dfsmisc.h>
  22. extern
  23. DWORD
  24. I_NetDfsIsThisADomainName(
  25. IN LPWSTR wszName);
  26. DFSSTATUS
  27. DfsIsThisAMachineName(
  28. LPWSTR MachineName )
  29. {
  30. DFSSTATUS Status;
  31. Status = DfsIsThisADomainName(MachineName);
  32. if (Status != NO_ERROR) {
  33. Status = ERROR_SUCCESS;
  34. }
  35. else {
  36. Status = ERROR_NO_MATCH;
  37. }
  38. return Status;
  39. }
  40. DFSSTATUS
  41. DfsIsThisAStandAloneDfsName(
  42. LPWSTR ServerName,
  43. LPWSTR ShareName )
  44. {
  45. DFSSTATUS Status = ERROR_SUCCESS;
  46. DWORD shareType = 0;
  47. PSHARE_INFO_1005 pshi1005 = NULL;
  48. LPWSTR CharHolder = NULL;
  49. BOOLEAN ShareModified = FALSE;
  50. CharHolder = wcschr(ShareName, UNICODE_PATH_SEP);
  51. if (CharHolder != NULL)
  52. {
  53. *CharHolder = UNICODE_NULL;
  54. ShareModified = TRUE;
  55. }
  56. Status = NetShareGetInfo(
  57. ServerName,
  58. ShareName,
  59. 1005,
  60. (PBYTE *) &pshi1005);
  61. if (ShareModified)
  62. {
  63. *CharHolder = UNICODE_PATH_SEP;
  64. }
  65. if (Status == NERR_Success)
  66. {
  67. shareType = pshi1005->shi1005_flags;
  68. NetApiBufferFree( pshi1005 );
  69. if(shareType & SHI1005_FLAGS_DFS_ROOT)
  70. {
  71. Status = ERROR_SUCCESS;
  72. }
  73. else
  74. {
  75. Status = NERR_NetNameNotFound;
  76. }
  77. }
  78. return Status;
  79. }
  80. DFSSTATUS
  81. DfsIsThisADomainName(
  82. LPWSTR DomainName )
  83. {
  84. ULONG Flags = 0;
  85. PDOMAIN_CONTROLLER_INFO pDomainControllerInfo;
  86. DFSSTATUS Status;
  87. Status = DsGetDcName(
  88. NULL, // Computername
  89. DomainName, // DomainName
  90. NULL, // DomainGuid
  91. NULL, // SiteGuid
  92. Flags,
  93. &pDomainControllerInfo);
  94. if (Status == NO_ERROR) {
  95. NetApiBufferFree(pDomainControllerInfo);
  96. }
  97. return Status;
  98. }
  99. DFSSTATUS
  100. DfsIsThisARealDfsName(
  101. LPWSTR ServerName,
  102. LPWSTR ShareName,
  103. BOOLEAN * IsDomainDfs )
  104. {
  105. DFSSTATUS Status = ERROR_SUCCESS;
  106. *IsDomainDfs = FALSE;
  107. Status = I_NetDfsIsThisADomainName(ServerName);
  108. if(Status != ERROR_SUCCESS)
  109. {
  110. Status = DfsIsThisAStandAloneDfsName(ServerName, ShareName);
  111. }
  112. else
  113. {
  114. *IsDomainDfs = TRUE;
  115. }
  116. return Status;
  117. }