00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef COMSTL_INCL_H_COMSTL
00060 # include "comstl.h"
00061 #endif
00062
00063 #if ( !defined(_WIN32_WINNT) || \
00064 (_WIN32_WINNT < 0x0400)) && \
00065 !defined(_WIN32_DCOM)
00066 # error This file can only be used in the context of DCOM compilations.
00067 #endif
00068
00069 #if _MSC_VER >= 1200
00070 # include <iaccess.h>
00071 #endif
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #ifndef _COMSTL_NO_NAMESPACE
00091 # if defined(_STLSOFT_NO_NAMESPACE) || \
00092 defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00093
00094 namespace comstl
00095 {
00096 # else
00097
00098
00099 namespace stlsoft
00100 {
00101
00102 namespace comstl_project
00103 {
00104
00105 # endif
00106 #endif
00107
00108
00109
00114
00115
00116
00117
00118
00119 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00120 const DWORD _EOAC_SEC_DESC = 0x0;
00121 const DWORD _EOAC_ACCESS_CONTROL = 0x4;
00122 const DWORD _EOAC_APPID = 0x8;
00123 const DWORD _EOAC_SECURITY_MASK = ( _EOAC_SEC_DESC |
00124 _EOAC_APPID |
00125 _EOAC_ACCESS_CONTROL);
00126 #endif
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00141 #ifdef __IAccessControl_INTERFACE_DEFINED__
00142 inline HRESULT CoInitSecurity( LPUNKNOWN punkAccessControl,
00143 DWORD cAuthSvc,
00144 SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
00145 DWORD dwAuthnLevel,
00146 DWORD dwImpLevel,
00147 RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
00148 DWORD dwCapabilities)
00149 {
00150 HRESULT hr;
00151 IAccessControl *pac;
00152
00153
00154 dwCapabilities &= ~_EOAC_SECURITY_MASK;
00155 dwCapabilities |= _EOAC_ACCESS_CONTROL;
00156
00157 hr = punkAccessControl->QueryInterface(IID_IAccessControl, (void**)&pac);
00158
00159 if(SUCCEEDED(hr))
00160 {
00161 hr = ::CoInitializeSecurity(pac, cAuthSvc, asAuthSvc, NULL, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities, NULL);
00162
00163 pac->Release();
00164 }
00165
00166 return hr;
00167 }
00168 #endif // __IAccessControl_INTERFACE_DEFINED__
00169
00172 inline HRESULT CoInitSecurity( const GUID &appid,
00173 DWORD cAuthSvc,
00174 SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
00175 DWORD dwAuthnLevel,
00176 DWORD dwImpLevel,
00177 RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
00178 DWORD dwCapabilities)
00179 {
00180
00181 dwCapabilities &= ~_EOAC_SECURITY_MASK;
00182 dwCapabilities |= _EOAC_APPID;
00183
00184 return ::CoInitializeSecurity((LPVOID)&appid, cAuthSvc, asAuthSvc, NULL, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities, NULL);
00185 }
00186
00189 inline HRESULT CoInitSecurity( SECURITY_DESCRIPTOR *psd,
00190 DWORD cAuthSvc,
00191 SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
00192 DWORD dwAuthnLevel,
00193 DWORD dwImpLevel,
00194 RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
00195 DWORD dwCapabilities)
00196 {
00197
00198 dwCapabilities &= ~_EOAC_SECURITY_MASK;
00199 dwCapabilities |= _EOAC_SEC_DESC;
00200
00201 return ::CoInitializeSecurity(psd, cAuthSvc, asAuthSvc, NULL, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities, NULL);
00202 }
00203
00205
00206
00207 #ifdef STLSOFT_UNITTEST
00208
00209 namespace unittest
00210 {
00211 ss_bool_t test_comstl_security_initialisers(unittest_reporter *r)
00212 {
00213 using stlsoft::unittest::unittest_initialiser;
00214
00215 ss_bool_t bSuccess = true;
00216
00217 unittest_initialiser init(r, "COMSTL", "security_initialisers", __FILE__);
00218
00219 #if 0
00220 if(<<TODO>>)
00221 {
00222 r->report("<<TODO>> failed ", __LINE__);
00223 bSuccess = false;
00224 }
00225 #endif
00226
00227 return bSuccess;
00228 }
00229
00230 unittest_registrar unittest_comstl_security_initialisers(test_comstl_security_initialisers);
00231
00232 }
00233
00234 #endif
00235
00236
00237
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 #endif
00251
00252
00253
00254
00255
00256