00001
00002
00003
00004
00005 #if ! defined( AFX_SD_H__C2404C08_2791_41F1_A45E_A62EF7364105__INCLUDED_ )
00006 #define AFX_SD_H__C2404C08_2791_41F1_A45E_A62EF7364105__INCLUDED_
00007 #pragma once
00008
00009
00010
00011 namespace fksec {
00012
00013 class sd
00014 {
00015 public:
00016
00017 enum AbsOrRel { AbsoluteSD, SelfRelativeSD };
00018
00019
00020
00021 sd();
00022
00023 sd( const sd &s );
00024
00025 sd( SECURITY_DESCRIPTOR *s );
00026 sd( SECURITY_DESCRIPTOR_RELATIVE *s );
00027
00028 sd( WORD newControl, const PSID newOwner, const PSID newGroup, ACL *newDacl, ACL *newSacl );
00029
00030 virtual ~sd();
00031
00032
00033
00034 const sd &operator=( const sd &s );
00035
00036 const sd &operator=( SECURITY_DESCRIPTOR *s );
00037 const sd &operator=( SECURITY_DESCRIPTOR_RELATIVE *s );
00038
00039
00040
00041
00042
00043
00044
00045 operator SECURITY_DESCRIPTOR *() const;
00046
00047 operator SECURITY_DESCRIPTOR_RELATIVE *() const;
00048
00049
00050
00051 WORD GetControl() const;
00053 DWORD GetRevision() const;
00054
00055 SECURITY_INFORMATION GetSecurityInformation() const;
00056
00057 const sid &GetOwnerSid() const;
00058 sid &GetOwnerSid();
00059
00060 const sid &GetGroupSid() const;
00061 sid &GetGroupSid();
00062
00063 const acl &GetDacl() const;
00064 acl &GetDacl();
00065
00066 const acl &GetSacl() const;
00067 acl &GetSacl();
00068
00069
00070 void SetControl( WORD newControl );
00071
00072 void ClearOwnerSid();
00073 void SetOwnerSid( const sid &newSid );
00074 void SetOwnerSid( const PSID psid );
00075 void SetOwnerSid( const TCHAR *stringSid );
00076
00077 void ClearGroupSid();
00078 void SetGroupSid( const sid &newSid );
00079 void SetGroupSid( const PSID psid );
00080 void SetGroupSid( const TCHAR *stringSid );
00081
00082
00083 void ClearDacl();
00084 void SetDacl( const acl &newAcl );
00085 void SetDacl( ACL *newAcl );
00086 bool GetDaclProtection() const;
00087 void SetDaclProtection( bool newProtection );
00088
00089
00090 void ClearSacl();
00091 void SetSacl( const acl &newAcl );
00092 void SetSacl( ACL *newAcl );
00093 bool GetSaclProtection() const;
00094 void SetSaclProtection( bool newProtection );
00095
00096
00097
00098 friend fkostream &operator<<( fkostream &o, const sd &s );
00099
00100 DWORD GetLength() const;
00101
00102 void StoreSd( SECURITY_DESCRIPTOR *p, DWORD &sz, AbsOrRel sdtype = AbsoluteSD ) const;
00103
00104 bool IsValid( bool checkPSD = true ) const;
00105
00106 bool IsObjectSD() const ;
00107
00108 private:
00109
00110 void Init();
00111
00112 void ClearPSD();
00113
00114 void ReleasePSD();
00115
00116 void MakePSD() const;
00117
00118
00119 WORD control;
00120 DWORD revision;
00121 bool haveOwnerSid;
00122 fksec::sid ownerSid;
00123 bool haveGroupSid;
00124 fksec::sid groupSid;
00125 bool haveDacl;
00126 bool protectedDacl;
00127 fksec::acl dacl;
00128 bool haveSacl;
00129 bool protectedSacl;
00130 fksec::acl sacl;
00131
00132
00133 mutable bool haveAbsoluteSD;
00134 mutable SECURITY_DESCRIPTOR *absoluteSD;
00135 mutable bool haveSelfRelativeSD;
00136 mutable SECURITY_DESCRIPTOR *selfRelativeSD;
00137
00138
00139 static fksec::sid invalidSid;
00140 static fksec::acl invalidAcl;
00141 };
00142
00143
00144 fkostream &operator<<( fkostream &o, const sd &s );
00145
00146 }
00147
00148 #endif // ! defined( AFX_SD_H__C2404C08_2791_41F1_A45E_A62EF7364105__INCLUDED_ )