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.

116 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1998 - 1998 Microsoft Corporation
  3. Module Name: utils.h
  4. Abstract: This Module implements the utility routines for dsacls
  5. Author: hitesh raigandhi (hiteshr )
  6. Environment:User Mode
  7. Revision History:
  8. --*/
  9. #ifndef _DSACLS_UTIL_H
  10. #define _DSACLS_UTIL_H
  11. #include "accctrl.h"
  12. DWORD GetAccountNameFromSid( LPWSTR pszServerName,
  13. PSID pSid,
  14. LPWSTR *pszName );
  15. DWORD GetSidFromAccountName( LPWSTR pszServerName,
  16. PSID *ppSid,
  17. LPWSTR pszName );
  18. DWORD GetGlobalNamingContexts( LPWSTR szObjectPath,
  19. LPWSTR * pszSchemaNamingContext ,
  20. LPWSTR * pszConfigurationNamingContext );
  21. BOOL FormatStringGUID( LPWSTR lpszBuf,
  22. UINT nBufSize,
  23. const GUID* pGuid);
  24. PSID GetAceSid(PACE_HEADER pAce);
  25. BOOL GuidFromString( GUID* pGuid,
  26. LPCWSTR lpszGuidString);
  27. DWORD GetServerName( IN LPWSTR pszObjectName,
  28. OUT LPWSTR *pszServerName );
  29. DWORD LoadMessage( IN DWORD MessageId,
  30. LPWSTR *ppszLoadString,
  31. ... );
  32. DWORD BuildLdapPath( LPWSTR * ppszLdapPath,
  33. LPWSTR pszServerName,
  34. LPWSTR pszPath );
  35. void StringWithNSpace( UINT n,
  36. LPWSTR szSpace );
  37. VOID DisplayString( UINT nIdent,
  38. LPWSTR pszDisplay );
  39. VOID DisplayStringWithNewLine( UINT nIdent,
  40. LPWSTR pszDisplay );
  41. VOID DisplayNewLine();
  42. DWORD DisplayMessageEx( IN DWORD Indent,
  43. IN DWORD MessageId,
  44. ... );
  45. VOID DisplayMessage( IN DWORD Indent,
  46. IN DWORD MessageId,
  47. ... );
  48. VOID DisplayErrorMessage( IN DWORD Error );
  49. DWORD ConvertStringAToStringW ( IN PSTR AString,
  50. OUT PWSTR *WString );
  51. DWORD CopyUnicodeString( LPWSTR * strDst,
  52. LPWSTR strSrc );
  53. DWORD GetProtection( PSECURITY_DESCRIPTOR pSD,
  54. SECURITY_INFORMATION * pSI );
  55. //AutoBstr taken from burnslib
  56. // A BSTR wrapper that frees itself upon destruction.
  57. //
  58. // From Box, D. Essential COM. pp 80-81. Addison-Wesley. ISBN 0-201-63446-5
  59. class AutoBstr
  60. {
  61. public:
  62. explicit
  63. AutoBstr(const wchar_t* s)
  64. :
  65. bstr(::SysAllocString(s))
  66. {
  67. ASSERT(s);
  68. }
  69. ~AutoBstr()
  70. {
  71. ::SysFreeString(bstr);
  72. bstr = 0;
  73. }
  74. operator BSTR () const
  75. {
  76. return bstr;
  77. }
  78. private:
  79. BSTR bstr;
  80. };
  81. #endif