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.

122 lines
2.5 KiB

  1. ///**************************************************************
  2. /// Microsoft LAN Manager *
  3. /// Copyright(c) Microsoft Corp., 1990 *
  4. ///**************************************************************
  5. //
  6. // This program is designed to do functional testing on the following
  7. // APIs:
  8. // NetUserModalsGet
  9. // NetUserModalsSet
  10. //
  11. // This test can be run independently of other tests.
  12. //
  13. //
  14. #include <nt.h> // TIME definition
  15. #include <ntrtl.h> // TIME definition
  16. #include <nturtl.h> // TIME definition
  17. #define NOMINMAX // Avoid redefinition of min and max in stdlib.h
  18. #include <windef.h>
  19. #include <winbase.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <lmcons.h>
  24. #include <lmapibuf.h>
  25. #include <netlib.h>
  26. #include <netdebug.h>
  27. #include <lmaccess.h>
  28. #include <lmerr.h>
  29. #include <ntsam.h>
  30. #include "accessp.h"
  31. #include "netlogon.h"
  32. #include "logonp.h"
  33. //
  34. // SetRole()
  35. //
  36. void
  37. SetRole(
  38. DWORD Role
  39. )
  40. {
  41. DWORD err;
  42. PUSER_MODALS_INFO_1 um1p;
  43. USER_MODALS_INFO_1006 um1006;
  44. //
  45. // setup data for update
  46. //
  47. um1006.usrmod1006_role = Role;
  48. if (err = NetUserModalsSet(NULL, 1006, (LPBYTE)&um1006, NULL)) {
  49. printf("NetUserModalsSet failed %d \n", err);
  50. return;
  51. } else {
  52. //
  53. // verify set data
  54. //
  55. if (err = NetUserModalsGet(NULL, 1, (LPBYTE *) &um1p)) {
  56. printf("NetUserModalsGet failed %d \n", err);
  57. return;
  58. } else {
  59. //
  60. // verify initial settings
  61. //
  62. if( um1p->usrmod1_role != Role ) {
  63. printf("Verify ROLE failed \n");
  64. }
  65. else {
  66. printf("SamRole set successfully");
  67. }
  68. NetApiBufferFree( um1p );
  69. }
  70. }
  71. return;
  72. }
  73. void __cdecl
  74. main(argc, argv)
  75. int argc;
  76. char **argv;
  77. {
  78. DWORD Role;
  79. if( argc < 2 ) {
  80. printf("Usage : SamRole [ Primary | Backup ] \n" );
  81. return;
  82. }
  83. if(_stricmp( argv[1], "Primary" ) == 0) {
  84. Role = UAS_ROLE_PRIMARY;
  85. } else if( _stricmp(argv[1], "Backup") == 0) {
  86. Role = UAS_ROLE_BACKUP;
  87. } else {
  88. printf("Usage : SamRole [ Primary | Backup ] \n" );
  89. return;
  90. }
  91. SetRole(Role);
  92. }