Source code of Windows XP (NT5)
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.

116 lines
3.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // ntdsuser.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file defines the class NTDSUser.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/24/1998 Original version.
  16. // 04/16/1998 Added Initialize/Shutdown.
  17. // 04/30/1998 Do not process rejects.
  18. // Disable handler when NTDS unavailable.
  19. // 05/04/1998 Implement Suspend/Resume.
  20. // 05/19/1998 Converted to NtSamHandler.
  21. // 06/02/1998 Log warnings when going from mixed to native.
  22. // 06/03/1998 Always use LDAP against native-mode domains.
  23. // 06/22/1998 Force a rebind if access check fails.
  24. // 07/01/1998 Handle LDAP_PARTIAL_RESULTS.
  25. // 07/08/1998 Use server control to suppress SACL.
  26. // 07/13/1998 Clean up header file dependencies.
  27. // 08/10/1998 Only process domain users.
  28. // 03/10/1999 Only process native-mode domains.
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. #include <ias.h>
  32. #include <iaslsa.h>
  33. #include <iasntds.h>
  34. #include <autohdl.h>
  35. #include <ldapdnary.h>
  36. #include <userschema.h>
  37. #include <ntdsuser.h>
  38. //////////
  39. // Attributes that should be retrieved for each user.
  40. //////////
  41. const PCWSTR PER_USER_ATTRS[] =
  42. {
  43. L"msNPAllowDialin",
  44. L"msNPCallingStationID",
  45. L"msRADIUSCallbackNumber",
  46. L"msRADIUSFramedIPAddress",
  47. L"msRADIUSFramedRoute",
  48. L"msRADIUSServiceType",
  49. NULL
  50. };
  51. //////////
  52. // Dictionary used for converting returned attributes.
  53. //////////
  54. const LDAPDictionary theDictionary(USER_SCHEMA_ELEMENTS, USER_SCHEMA);
  55. HRESULT NTDSUser::initialize() throw ()
  56. {
  57. DWORD error = IASNtdsInitialize();
  58. return HRESULT_FROM_WIN32(error);
  59. }
  60. void NTDSUser::finalize() throw ()
  61. {
  62. IASNtdsUninitialize();
  63. }
  64. IASREQUESTSTATUS NTDSUser::processUser(
  65. IASRequest& request,
  66. PCWSTR domainName,
  67. PCWSTR username
  68. )
  69. {
  70. // We only handle native-mode domains.
  71. if (!IASNtdsIsNativeModeDomain(domainName))
  72. {
  73. return IAS_REQUEST_STATUS_INVALID;
  74. }
  75. IASTraceString("Using native-mode dial-in parameters.");
  76. //////////
  77. // Query the DS.
  78. //////////
  79. DWORD error;
  80. auto_handle< PLDAPMessage,
  81. ULONG (LDAPAPI*)(PLDAPMessage),
  82. &ldap_msgfree
  83. > res;
  84. error = IASNtdsQueryUserAttributes(
  85. domainName,
  86. username,
  87. LDAP_SCOPE_SUBTREE,
  88. const_cast<PWCHAR*>(PER_USER_ATTRS),
  89. &res
  90. );
  91. if (error == NO_ERROR)
  92. {
  93. // We got something back, so insert the attributes.
  94. theDictionary.insert(request, res);
  95. IASTraceString("Successfully retrieved per-user attributes.");
  96. return IAS_REQUEST_STATUS_HANDLED;
  97. }
  98. // We have a DS for this user, but we can't talk to it.
  99. error = IASMapWin32Error(error, IAS_DOMAIN_UNAVAILABLE);
  100. return IASProcessFailure(request, error);
  101. }