Listing 4 Extracts from SID.h & SID.cpp
namespace SynSoft { namespace Security { // SID.h public __gc class SID : public IDisposable { public: SID(void *psid); ~SID(); // IDisposable public: void Close(); void Dispose(); // Properties public: // Returns a string representation of the SID String *ToString(); // The type of the SID __property SidType get_Type(); // The name of the user associated with the SID __property String *get_UserName(); // The name of the domain associated with the SID __property String *get_DomainName(); // Members private: void *m_psid; SidType m_type; String *m_userName; String *m_domainName; String *m_stringForm; }; // SID.cpp SID::SID(void *psid) : m_psid(Sec_SidDup(psid)) , m_type(SidType::Unknown) , m_userName(0) , m_domainName(0) , m_stringForm(0) { // Now we get the user and domain names if(0 == psid) { throw new SecurityException(E_INVALIDARG, "NULL SID"); } else if(!::IsValidSid(psid)) { throw new SecurityException(::GetLastError(), "Invalid SID"); } else { . . . } } SID::~SID() { if(0 != m_psid) { Sec_Free(m_psid); } } void SID::Close() { if(0 != m_psid) { Sec_Free(m_psid); m_psid = 0; } } void SID::Dispose() { Close(); } . . . } }