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.

109 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. ds.c
  5. Abstract:
  6. Interface from netlogon to the DS.
  7. Author:
  8. Cliff Van Dyke (CliffV) 24-Apr-1996
  9. Revision History:
  10. --*/
  11. //
  12. // Common include files.
  13. //
  14. #include "logonsrv.h" // Include files common to entire service
  15. #pragma hdrstop
  16. //
  17. // Include files specific to this .c file
  18. //
  19. NET_API_STATUS
  20. NlGetRoleInformation(
  21. PDOMAIN_INFO DomainInfo,
  22. PBOOLEAN IsPdc,
  23. PBOOLEAN Nt4MixedDomain
  24. )
  25. /*++
  26. Routine Description:
  27. This routine gets the information from the DS we need to determine our
  28. role.
  29. Arguments:
  30. DomainInfo - Domain the role is being determined for
  31. IsPdc - TRUE if this machine is the PDC
  32. Nt4MixedDomain - TRUE if there are NT 4 DCs in this domain.
  33. Return Value:
  34. Status of the operation.
  35. --*/
  36. {
  37. NET_API_STATUS NetStatus;
  38. NTSTATUS Status;
  39. PSAMPR_DOMAIN_INFO_BUFFER DomainServerRole = NULL;
  40. //
  41. // Ask Sam if this is a mixed domain.
  42. //
  43. *Nt4MixedDomain = SamIMixedDomain( DomainInfo->DomSamServerHandle );
  44. //
  45. // The SAM account domain has the authoritative copy of the machine's role
  46. //
  47. Status = SamrQueryInformationDomain( DomainInfo->DomSamAccountDomainHandle,
  48. DomainServerRoleInformation,
  49. &DomainServerRole );
  50. if ( !NT_SUCCESS(Status) ) {
  51. NlPrintDom(( NL_CRITICAL, DomainInfo,
  52. "NlGetRoleInformation: Cannot SamQueryInformationDomain (Role): %lx\n",
  53. Status ));
  54. NetStatus = NetpNtStatusToApiStatus( Status );
  55. DomainServerRole = NULL;
  56. goto Cleanup;
  57. }
  58. if ( DomainServerRole->Role.DomainServerRole == DomainServerRolePrimary ) {
  59. *IsPdc = TRUE;
  60. } else {
  61. *IsPdc = FALSE;
  62. }
  63. NetStatus = NERR_Success;
  64. Cleanup:
  65. //
  66. // Free locally used resources.
  67. //
  68. if ( DomainServerRole != NULL ) {
  69. SamIFree_SAMPR_DOMAIN_INFO_BUFFER( DomainServerRole,
  70. DomainServerRoleInformation);
  71. }
  72. return NetStatus;
  73. }