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.

98 lines
2.4 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 "..\..\lib\dfsgram\dfsobjectdef.h"
  10. #include <dfsadmin.h>
  11. DFSSTATUS
  12. SetTarget(
  13. LPWSTR LinkOrRoot,
  14. PTARGET_DEF pTarget,
  15. BOOLEAN FirstTarget)
  16. {
  17. DFSSTATUS Status;
  18. if (IsInScript(pTarget) && IsInNameSpace(pTarget))
  19. {
  20. Status = ERROR_SUCCESS;
  21. }
  22. else if (IsInScript(pTarget))
  23. {
  24. Status = AddNewTarget( LinkOrRoot, pTarget, FirstTarget);
  25. }
  26. else if (IsInNameSpace(pTarget))
  27. {
  28. Status = DeleteTarget( LinkOrRoot, pTarget );
  29. // printf("Delete Target Status for %wS, %wS %x\n", LinkOrRoot, pTarget->Name, Status);
  30. }
  31. else
  32. {
  33. printf("SetTarget: Target %wS has error!\n", pTarget->Name);
  34. Status = ERROR_GEN_FAILURE;
  35. }
  36. return Status;
  37. }
  38. DFSSTATUS
  39. SetLink(
  40. LPWSTR RootNameString,
  41. PLINK_DEF pLink)
  42. {
  43. DFSSTATUS Status = ERROR_SUCCESS;
  44. DFSSTATUS TargetStatus = ERROR_SUCCESS;
  45. PTARGET_DEF pTarget;
  46. UNICODE_STRING LinkName;
  47. BOOLEAN FirstTarget = FALSE;
  48. if (!IsObjectInScript(pLink))
  49. {
  50. if (IsObjectInNameSpace(pLink))
  51. {
  52. Status = DeleteLink( RootNameString, pLink);
  53. }
  54. else
  55. {
  56. printf("Set Link error! \n");
  57. Status = ERROR_GEN_FAILURE;
  58. }
  59. }
  60. else {
  61. if (!IsObjectInNameSpace(pLink))
  62. {
  63. AddLinks++;
  64. FirstTarget = TRUE;
  65. }
  66. Status = DfsCreateUnicodePathString(&LinkName, FALSE, RootNameString, pLink->LinkObjectName);
  67. if (Status == ERROR_SUCCESS)
  68. {
  69. for (pTarget = pLink->LinkObjectTargets; pTarget != NULL; pTarget = pTarget->NextTarget)
  70. {
  71. TargetStatus = SetTarget(LinkName.Buffer, pTarget, FirstTarget);
  72. if (TargetStatus != ERROR_SUCCESS)
  73. {
  74. Status = ERROR_GEN_FAILURE;
  75. }
  76. FirstTarget = FALSE;
  77. }
  78. if (Status == ERROR_SUCCESS)
  79. {
  80. Status = UpdateLinkMetaInformation( &LinkName, pLink );
  81. }
  82. DfsFreeUnicodeString(&LinkName);
  83. }
  84. }
  85. return Status;
  86. }