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.

95 lines
3.4 KiB

  1. class CCred; // forward reference
  2. //+---------------------------------------------------------------------------
  3. // _____ ___ _ _ _____ ___ _ _ _ _
  4. // / __\ \ / (_)_ _ | \| |_ _/ __|_ _ ___ __| |___ _ _| |_(_)__ _| |___
  5. // | (__ \ \/\/ /| | ' \| .` | | || (__| '_/ -_) _` / -_) ' \ _| / _` | (_-<
  6. // \___| \_/\_/ |_|_||_|_|\_| |_| \___|_| \___\__,_\___|_||_\__|_\__,_|_/__/
  7. //
  8. // Class CWinNTCredentials - encapsulates permissions on a server's
  9. // ADMIN$ resource.
  10. //
  11. // The most common use of this object will be passing it around between
  12. // objects. To do this, add lines like these to the new object's
  13. // create() method:
  14. //
  15. // CNewObj::CreateNewObj(CWinNTCredentials& Credentials, ...)
  16. // { // ...
  17. // pNewObj->_Credentials = Credentials;
  18. // hr = pNewObj->_Credentials->ref(pszServerName);
  19. // BAIL_ON_FAILURE(hr);
  20. // // ...
  21. // }
  22. //
  23. // The CWinNTCredentials object's destructor takes care of dereferencing
  24. // the internal object automatically.
  25. //
  26. //
  27. // Constructors:
  28. // CWinNTCredentials() - create an empty CWinNTCredentials
  29. // CWinNTCredentials( - copies a CWinNTCredentials object
  30. // const CWinNTCredentials&)
  31. // CWinNTCredentials( - create a CWinNTCredentials with a
  32. // PWSTR pszUserName, username and password. This does
  33. // PWSTR pszPassword) not bind to a server.
  34. //
  35. // Public methods:
  36. // GetUserName - get the username of the credentials
  37. // GetPassword - get the password of the credentials
  38. // Bound - TRUE iff this object has a reference
  39. // to a server.
  40. // ref - add a reference to this object
  41. // and connect to the server if
  42. // necessary
  43. //
  44. //----------------------------------------------------------------------------
  45. class CWinNTCredentials
  46. {
  47. public:
  48. CWinNTCredentials();
  49. CWinNTCredentials(
  50. PWSTR pszUserName,
  51. PWSTR pszPassword,
  52. DWORD dwFlags = 0
  53. );
  54. CWinNTCredentials(const CWinNTCredentials& Credentials);
  55. ~CWinNTCredentials();
  56. const CWinNTCredentials& operator=(const CWinNTCredentials& other);
  57. HRESULT RefServer(PWSTR pszServer, BOOL fAllowRebinding = FALSE);
  58. HRESULT RefDomain(PWSTR pszDomain);
  59. HRESULT Ref(PWSTR pszServer, PWSTR pszDomain, DWORD dwType);
  60. HRESULT GetUserName(PWSTR *ppszUserName);
  61. HRESULT GetPassword(PWSTR * ppszPassword);
  62. BOOL Bound();
  63. // AjayR we need these two methods for use from objects
  64. // that get a reference to a Credentials object but that
  65. // never make a copy of the object - particularly for getobj.cxx
  66. // and cobjcach.cxx
  67. HRESULT DeRefServer();
  68. HRESULT DeRefDomain();
  69. DWORD GetFlags() const;
  70. void SetFlags(DWORD dwFlags);
  71. void SetUmiFlag(void);
  72. void ResetUmiFlag(void);
  73. private:
  74. // AjayR addition :
  75. // This is called by the destructor and other routines
  76. // where we need to clear the m_pCred object - reduce its
  77. // usage count, deref and delete if necessary.
  78. //
  79. void Clear_pCredObject();
  80. DWORD m_cRefAdded;
  81. CCred *m_pCred;
  82. DWORD m_dwFlags;
  83. };