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
2.6 KiB

  1. #ifndef _LSAKEYS_H_
  2. #define _LSAKEYS_H_
  3. #ifndef _CHICAGO_
  4. // This class is to help setup retrieve the old-style LSA keys and convert them
  5. // into the new MetaData keys.
  6. // error codes
  7. enum {
  8. KEYLSA_SUCCESS = 0,
  9. KEYLSA_INVALID_VERSION,
  10. KEYLSA_NO_MORE_KEYS,
  11. KEYLSA_UNABLE_TO_OPEN_POLICY
  12. };
  13. // Note: once you call LoadFirstKey, there is an open LSA policy until the object is deleted.
  14. // This is done for speed purposes. So if you don't want the policy hanging around, don't
  15. // keep the object around.
  16. class CLSAKeys : public CObject
  17. {
  18. public:
  19. // construction
  20. CLSAKeys();
  21. ~CLSAKeys();
  22. // loading the keys
  23. // LoadFirstKey loads the first key on the specified target machine. Until
  24. // this method is called, the data values in the object are meaningless
  25. DWORD LoadFirstKey( PWCHAR pszwTargetMachine );
  26. // LoadNextKey loads the next key on the target machine specified in LoadFirstKey
  27. // LoadNextKey automatically cleans up the memory used by the previous key.
  28. DWORD LoadNextKey();
  29. // DeleteAllLSAKeys deletes ALL remenents of the LSA keys in the Metabase.
  30. // (not including, of course anything written out there in the future as part
  31. // of some backup scheme when uninstalling). Call this only AFTER ALL the keys
  32. // have been converted to the metabase. They will no longer be there after
  33. // this routine is used.
  34. DWORD DeleteAllLSAKeys();
  35. // the data values that are to be filled in.
  36. // The public portion of the key - may be NULL and zero size
  37. DWORD m_cbPublic;
  38. PVOID m_pPublic;
  39. // the private portion of the key
  40. DWORD m_cbPrivate;
  41. PVOID m_pPrivate;
  42. // the password
  43. DWORD m_cbPassword;
  44. PVOID m_pPassword;
  45. // the certificate request - may be NULL and zero size
  46. DWORD m_cbRequest;
  47. PVOID m_pRequest;
  48. // the friendly name
  49. CHAR m_szFriendlyName[256];
  50. // the name that should be given to the metabase object for this key
  51. CHAR m_szMetaName[256];
  52. private:
  53. // clean up the currently loaded key
  54. void UnloadKey();
  55. // delete utilities
  56. DWORD DeleteKMKeys();
  57. DWORD DeleteServerKeys();
  58. // LSA Utility routines
  59. HANDLE HOpenLSAPolicy( PWCHAR pszwServer, DWORD *pErr );
  60. BOOL FCloseLSAPolicy( HANDLE hPolicy, DWORD *pErr );
  61. BOOL FStoreLSASecret( HANDLE hPolicy, WCHAR* pszwSecretName, void* pvData, WORD cbData, DWORD *pErr );
  62. PLSA_UNICODE_STRING FRetrieveLSASecret( HANDLE hPolicy, WCHAR* pszwSecretName, DWORD *pErr );
  63. void DisposeLSAData( PVOID pData );
  64. // the handle to the LSA policy
  65. HANDLE m_hPolicy;
  66. // index of the current key
  67. DWORD m_iKey;
  68. };
  69. #endif //_CHICAGO_
  70. #endif //_LSAKEYS_H_