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.

91 lines
2.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Defines the class NTDSUser.
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include <ias.h>
  11. #include <iaslsa.h>
  12. #include <iasntds.h>
  13. #include <ldapdnary.h>
  14. #include <userschema.h>
  15. #include <ntdsuser.h>
  16. //////////
  17. // Attributes that should be retrieved for each user.
  18. //////////
  19. const PCWSTR PER_USER_ATTRS[] =
  20. {
  21. L"msNPAllowDialin",
  22. L"msNPCallingStationID",
  23. L"msRADIUSCallbackNumber",
  24. L"msRADIUSFramedIPAddress",
  25. L"msRADIUSFramedRoute",
  26. L"msRADIUSServiceType",
  27. NULL
  28. };
  29. //////////
  30. // Dictionary used for converting returned attributes.
  31. //////////
  32. const LDAPDictionary theDictionary(USER_SCHEMA_ELEMENTS, USER_SCHEMA);
  33. HRESULT NTDSUser::initialize() throw ()
  34. {
  35. DWORD error = IASNtdsInitialize();
  36. return HRESULT_FROM_WIN32(error);
  37. }
  38. void NTDSUser::finalize() throw ()
  39. {
  40. IASNtdsUninitialize();
  41. }
  42. IASREQUESTSTATUS NTDSUser::processUser(
  43. IASRequest& request,
  44. PCWSTR domainName,
  45. PCWSTR username
  46. )
  47. {
  48. // We only handle native-mode domains.
  49. if (!IASNtdsIsNativeModeDomain(domainName))
  50. {
  51. return IAS_REQUEST_STATUS_INVALID;
  52. }
  53. IASTraceString("Using native-mode dial-in parameters.");
  54. //////////
  55. // Query the DS.
  56. //////////
  57. DWORD error;
  58. IASNtdsResult result;
  59. error = IASNtdsQueryUserAttributes(
  60. domainName,
  61. username,
  62. LDAP_SCOPE_SUBTREE,
  63. const_cast<PWCHAR*>(PER_USER_ATTRS),
  64. &result
  65. );
  66. if (error == NO_ERROR)
  67. {
  68. // We got something back, so insert the attributes.
  69. theDictionary.insert(request, result.msg);
  70. IASTraceString("Successfully retrieved per-user attributes.");
  71. return IAS_REQUEST_STATUS_HANDLED;
  72. }
  73. // We have a DS for this user, but we can't talk to it.
  74. error = IASMapWin32Error(error, IAS_DOMAIN_UNAVAILABLE);
  75. return IASProcessFailure(request, error);
  76. }