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.

781 lines
20 KiB

  1. //Implementation of CAuthMethods class
  2. #include "stdafx.h"
  3. #include "Pop3Auth.h"
  4. #include "AuthMethodsEnum.h"
  5. #include <pop3regkeys.h>
  6. #include <p3admin.h>
  7. #include <DSRole.h>
  8. #include <POP3Server.h>
  9. #include <servutil.h>
  10. CAuthMethods::CAuthMethods()
  11. {
  12. m_bIsInitialized=FALSE;
  13. m_lCurrentMethodIndex=-1;
  14. m_bstrServerName=NULL;
  15. m_lMachineRole=0;
  16. InitializeCriticalSection(&m_csVectorGuard);
  17. }
  18. CAuthMethods::~CAuthMethods()
  19. {
  20. CleanUp();
  21. DeleteCriticalSection(&m_csVectorGuard);
  22. }
  23. STDMETHODIMP CAuthMethods::get_Count(LONG *pVal)
  24. {
  25. if(NULL == pVal)
  26. {
  27. return E_POINTER;
  28. }
  29. if(!m_bIsInitialized)
  30. {
  31. if(!Initialize())
  32. {
  33. return E_FAIL;
  34. }
  35. }
  36. *pVal=m_Index.size();
  37. return S_OK;
  38. }
  39. STDMETHODIMP CAuthMethods::get_Item(VARIANT vID, IAuthMethod **ppVal)
  40. {
  41. HRESULT hr=E_INVALIDARG;
  42. if(NULL == ppVal)
  43. {
  44. return E_POINTER;
  45. }
  46. if(! m_bIsInitialized)
  47. {
  48. if(!Initialize())
  49. {
  50. return E_FAIL;
  51. }
  52. }
  53. if(VT_I4 == vID.vt)
  54. {
  55. vID.lVal--; // Collections should be 1-based
  56. if(vID.lVal>=0 && vID.lVal<m_Index.size())
  57. {
  58. hr=m_AuthVector[m_Index[vID.lVal]]->pIAuthMethod
  59. ->QueryInterface(IID_IAuthMethod, (void **)ppVal);
  60. }
  61. }
  62. else if(VT_BSTR==vID.vt)
  63. {
  64. for(long i=0; i< m_Index.size(); i++)
  65. {
  66. if( 0==wcscmp(m_AuthVector[m_Index[i]]->bstrName, vID.bstrVal) )
  67. {
  68. hr=m_AuthVector[m_Index[i]]->pIAuthMethod
  69. ->QueryInterface(IID_IAuthMethod, (void **)ppVal);
  70. break;
  71. }
  72. }
  73. }
  74. if(S_OK==hr)
  75. {
  76. VARIANT vServer;
  77. vServer.vt=VT_BSTR;
  78. vServer.bstrVal=m_bstrServerName;
  79. if(m_bstrServerName!=NULL)
  80. {
  81. hr = (*ppVal)->Put(SZ_SERVER_NAME, vServer);
  82. }
  83. }
  84. return hr;
  85. }
  86. STDMETHODIMP CAuthMethods::get__NewEnum(IEnumVARIANT **ppVal)
  87. {
  88. if(ppVal==NULL)
  89. {
  90. return E_POINTER;
  91. }
  92. HRESULT hr=S_OK;
  93. CComObject<CAuthMethodsEnum> *pAuthEnum;
  94. *ppVal=NULL;
  95. if(!m_bIsInitialized)
  96. {
  97. if(!Initialize())
  98. {
  99. return E_FAIL;
  100. }
  101. }
  102. hr = CComObject<CAuthMethodsEnum>::CreateInstance(&pAuthEnum); // Reference count still 0
  103. if(SUCCEEDED(hr))
  104. {
  105. hr=pAuthEnum->Init(&m_AuthVector);
  106. if(SUCCEEDED(hr))
  107. {
  108. hr=pAuthEnum->QueryInterface(IID_IEnumVARIANT,(void **)(ppVal) );
  109. }
  110. if(FAILED(hr))
  111. {
  112. delete(pAuthEnum);
  113. }
  114. }
  115. return hr;
  116. }
  117. STDMETHODIMP CAuthMethods::Add(BSTR bstrName, BSTR bstrGUID)
  118. {
  119. HRESULT hr=S_OK;;
  120. PAUTH_METHOD_INFO pAuthMethodInfo=NULL;
  121. if(NULL==bstrName || NULL==bstrGUID)
  122. {
  123. return E_INVALIDARG;
  124. }
  125. pAuthMethodInfo=new(AUTH_METHOD_INFO);
  126. if(pAuthMethodInfo == NULL)
  127. {
  128. return E_OUTOFMEMORY;
  129. }
  130. pAuthMethodInfo->bstrGuid=SysAllocString(bstrGUID);
  131. pAuthMethodInfo->bstrName=SysAllocString(bstrName);
  132. if( (NULL==pAuthMethodInfo->bstrGuid)
  133. ||(NULL==pAuthMethodInfo->bstrName))
  134. {
  135. delete pAuthMethodInfo;
  136. hr=E_OUTOFMEMORY;
  137. }
  138. EnterCriticalSection(&m_csVectorGuard);
  139. m_AuthVector.push_back(pAuthMethodInfo);
  140. m_Index.push_back(m_AuthVector.size()-1);
  141. LeaveCriticalSection(&m_csVectorGuard);
  142. return hr;
  143. }
  144. STDMETHODIMP CAuthMethods::Remove(VARIANT vID)
  145. {
  146. HRESULT hr=E_INVALIDARG;
  147. AUTHINDEX::iterator itor=m_Index.begin();
  148. if(!m_bIsInitialized)
  149. {
  150. if(!Initialize())
  151. {
  152. return E_FAIL;
  153. }
  154. }
  155. if(m_Index.size()==1)
  156. {
  157. //Can not remove the last Auth method
  158. return E_FAIL;
  159. }
  160. if(VT_I4 == vID.vt)
  161. {
  162. vID.lVal--; // Collections should be 1-based
  163. if(vID.lVal>=0 && vID.lVal<m_Index.size())
  164. {
  165. itor+=vID.lVal;
  166. m_Index.erase(itor);
  167. if(vID.lVal==m_lCurrentMethodIndex)
  168. {
  169. m_lCurrentMethodIndex=0;
  170. }
  171. else if (vID.lVal<m_lCurrentMethodIndex)
  172. {
  173. m_lCurrentMethodIndex--;
  174. }
  175. }
  176. }
  177. else if(VT_BSTR==vID.vt)
  178. {
  179. for(int i=0; i< m_Index.size(); i++)
  180. {
  181. if(0==wcscmp(m_AuthVector[m_Index[i]]->bstrName, vID.bstrVal))
  182. {
  183. itor+=i;
  184. m_Index.erase(itor);
  185. if(i==m_lCurrentMethodIndex)
  186. {
  187. m_lCurrentMethodIndex=0;
  188. }
  189. else if (i<m_lCurrentMethodIndex)
  190. {
  191. m_lCurrentMethodIndex--;
  192. }
  193. break;
  194. }
  195. }
  196. }
  197. return hr;
  198. }
  199. STDMETHODIMP CAuthMethods::Save(void)
  200. {
  201. int i=0;
  202. int iBufferSize=0;
  203. WCHAR *pBuffer=NULL, *pCurrent;
  204. HRESULT hr=E_FAIL;
  205. HKEY hPop3Key;
  206. if( !m_bIsInitialized )
  207. {
  208. //No change needed for this save
  209. return S_OK;
  210. }
  211. EnterCriticalSection(&m_csVectorGuard);
  212. for(i=0;i<m_AuthVector.size();i++)
  213. {
  214. iBufferSize+=wcslen(m_AuthVector[i]->bstrGuid)+1;
  215. }
  216. if ( 0 != iBufferSize )
  217. {
  218. iBufferSize++;
  219. pBuffer=(WCHAR *)malloc(iBufferSize*sizeof(WCHAR));
  220. if(NULL != pBuffer)
  221. {
  222. pCurrent=pBuffer;
  223. for(i=0;i<m_AuthVector.size();i++)
  224. {
  225. wcscpy(pCurrent,m_AuthVector[i]->bstrGuid);
  226. pCurrent+=wcslen(m_AuthVector[i]->bstrGuid)+1;
  227. }
  228. *pCurrent=0; //Double NULL to terminate
  229. if( ERROR_SUCCESS== RegHKLMOpenKey(
  230. POP3SERVER_AUTH_SUBKEY,
  231. KEY_SET_VALUE,
  232. &hPop3Key,
  233. m_bstrServerName) )
  234. {
  235. if(ERROR_SUCCESS ==
  236. RegSetValueEx(hPop3Key,
  237. VALUENAME_AUTHMETHODS,
  238. NULL,
  239. REG_MULTI_SZ,
  240. (LPBYTE)pBuffer,
  241. iBufferSize*sizeof(WCHAR)))
  242. {
  243. if( ERROR_SUCCESS ==
  244. RegSetValueEx(hPop3Key,
  245. VALUENAME_DEFAULTAUTH,
  246. NULL,
  247. REG_DWORD,
  248. (LPBYTE)&(m_Index[m_lCurrentMethodIndex]),
  249. sizeof(DWORD)))
  250. { // Need to restart the service (if the Auth method is being changed, which means # domains = 0
  251. long lCount;
  252. CComPtr<IP3Config> spIConfig;
  253. CComPtr<IP3Domains> spIDomains;
  254. hr = CoCreateInstance( __uuidof( P3Config ), NULL, CLSCTX_ALL, __uuidof( IP3Config ),reinterpret_cast<LPVOID *>( &spIConfig ));
  255. if ( S_OK == hr )
  256. {
  257. hr = spIConfig->put_MachineName( m_bstrServerName );
  258. if ( S_OK == hr)
  259. {
  260. hr = spIConfig->get_Domains( &spIDomains );
  261. }
  262. }
  263. if( S_OK == hr )
  264. {
  265. hr = spIDomains->get_Count( &lCount );
  266. if ( S_OK == hr && 0 == lCount && _IsServiceRunning( POP3_SERVICE_NAME ))
  267. hr = _RestartService( POP3_SERVICE_NAME );
  268. }
  269. }
  270. }
  271. RegCloseKey(hPop3Key);
  272. }
  273. free(pBuffer);
  274. }
  275. else //pBuffer == NULL
  276. {
  277. hr=E_OUTOFMEMORY;
  278. }
  279. }
  280. LeaveCriticalSection(&m_csVectorGuard);
  281. return hr;
  282. }
  283. STDMETHODIMP CAuthMethods::put_MachineName(BSTR newVal)
  284. {
  285. if(NULL!=m_bstrServerName)
  286. {
  287. SysFreeString(m_bstrServerName);
  288. m_bstrServerName=NULL;
  289. }
  290. if ( (NULL != newVal) && (0 < wcslen( newVal )))
  291. {
  292. CleanUp();
  293. m_bstrServerName=SysAllocString(newVal);
  294. if(NULL==m_bstrServerName)
  295. {
  296. return E_OUTOFMEMORY;
  297. }
  298. }
  299. // Actually verify we can get the current auth method of the remote machine.
  300. // This enforces that we can only administer remote AD machine's if we are in the same domain.
  301. HRESULT hr;
  302. VARIANT v;
  303. CComPtr<IAuthMethod> spIAuthMethod;
  304. VariantInit( &v );
  305. hr = get_CurrentAuthMethod( &v );
  306. if ( S_OK == hr )
  307. hr = get_Item( v, &spIAuthMethod );
  308. if ( S_OK != hr )
  309. CleanUp();
  310. return hr;
  311. }
  312. STDMETHODIMP CAuthMethods::get_MachineName(BSTR *pVal)
  313. {
  314. if(NULL == pVal)
  315. {
  316. return E_POINTER;
  317. }
  318. if(NULL!=m_bstrServerName)
  319. {
  320. *pVal=SysAllocString(m_bstrServerName);
  321. if(NULL == *pVal)
  322. {
  323. return E_OUTOFMEMORY;
  324. }
  325. }
  326. else
  327. {
  328. *pVal=NULL;
  329. }
  330. return S_OK;
  331. }
  332. STDMETHODIMP CAuthMethods::get_CurrentAuthMethod(VARIANT *pVal)
  333. {
  334. if(NULL == pVal)
  335. {
  336. return E_POINTER;
  337. }
  338. if( !m_bIsInitialized)
  339. {
  340. if(!Initialize())
  341. {
  342. return E_FAIL;
  343. }
  344. }
  345. if(pVal->vt != VT_EMPTY )
  346. {
  347. return E_INVALIDARG;
  348. }
  349. if(m_lCurrentMethodIndex <0 )
  350. {
  351. //The current authmethod is not valid
  352. return HRESULT_FROM_WIN32(ERROR_DS_AUTH_METHOD_NOT_SUPPORTED);
  353. }
  354. pVal->vt=VT_I4;
  355. pVal->lVal=m_lCurrentMethodIndex + 1; // Collections should be 1-based
  356. return S_OK;
  357. }
  358. STDMETHODIMP CAuthMethods::put_CurrentAuthMethod(VARIANT vID)
  359. {
  360. HRESULT hr=E_INVALIDARG;
  361. if(!m_bIsInitialized)
  362. {
  363. if(!Initialize())
  364. {
  365. return E_FAIL;
  366. }
  367. }
  368. EnterCriticalSection(&m_csVectorGuard);
  369. if(VT_I4 == vID.vt)
  370. {
  371. vID.lVal--; // Collections should be 1-based
  372. if(vID.lVal>=0 && vID.lVal<m_Index.size())
  373. {
  374. hr=VerifyCurrentAuthMethod(vID.lVal);
  375. if(S_OK == hr )
  376. {
  377. m_lCurrentMethodIndex=vID.lVal;
  378. }
  379. }
  380. }
  381. else if(VT_BSTR==vID.vt)
  382. {
  383. for(int i=0; i< m_Index.size(); i++)
  384. {
  385. if( 0 == wcscmp(m_AuthVector[m_Index[i]]->bstrName, vID.bstrVal) )
  386. {
  387. hr=VerifyCurrentAuthMethod(i);
  388. if(S_OK == hr)
  389. {
  390. m_lCurrentMethodIndex=i;
  391. }
  392. break;
  393. }
  394. }
  395. }
  396. LeaveCriticalSection(&m_csVectorGuard);
  397. return hr;
  398. }
  399. void CAuthMethods::CleanUp()
  400. {
  401. for(int i=0; i< m_AuthVector.size(); i++)
  402. {
  403. if(NULL != m_AuthVector[i]->pIAuthMethod)
  404. {
  405. m_AuthVector[i]->pIAuthMethod->Release();
  406. }
  407. SysFreeString(m_AuthVector[i]->bstrGuid);
  408. SysFreeString(m_AuthVector[i]->bstrName);
  409. delete m_AuthVector[i];
  410. }
  411. m_AuthVector.clear();
  412. m_Index.clear();
  413. if(NULL!=m_bstrServerName)
  414. {
  415. SysFreeString(m_bstrServerName);
  416. m_bstrServerName=NULL;
  417. }
  418. m_bIsInitialized=FALSE;
  419. }
  420. BOOL CAuthMethods::Initialize()
  421. {
  422. HKEY hPop3Key;
  423. BOOL bRtVal=FALSE;
  424. DWORD cbSize=sizeof(DWORD);
  425. DWORD dwType;
  426. LONG lErr;
  427. LONG lCurrentMethodIndex=0;
  428. WCHAR *wBuffer=NULL;
  429. EnterCriticalSection(&m_csVectorGuard);
  430. if( !m_bIsInitialized )
  431. {
  432. SetMachineRole();
  433. //Load data from the registry
  434. if( ERROR_SUCCESS==RegHKLMOpenKey(
  435. POP3SERVER_AUTH_SUBKEY,
  436. KEY_QUERY_VALUE,
  437. &hPop3Key,
  438. m_bstrServerName) )
  439. {
  440. if(ERROR_SUCCESS==
  441. RegQueryValueEx(hPop3Key,
  442. VALUENAME_DEFAULTAUTH,
  443. NULL,
  444. &dwType,
  445. (LPBYTE)&(lCurrentMethodIndex),
  446. &cbSize))
  447. {
  448. cbSize=0;
  449. if(ERROR_SUCCESS==
  450. RegQueryValueEx(hPop3Key,
  451. VALUENAME_AUTHMETHODS,
  452. NULL,
  453. &dwType,
  454. NULL,
  455. &cbSize))
  456. {
  457. wBuffer=(WCHAR *)malloc(cbSize);
  458. if(NULL!=wBuffer)
  459. {
  460. ZeroMemory(wBuffer, cbSize);
  461. if(ERROR_SUCCESS==
  462. RegQueryValueEx(hPop3Key,
  463. VALUENAME_AUTHMETHODS,
  464. NULL,
  465. &dwType,
  466. (LPBYTE)wBuffer,
  467. &cbSize))
  468. {
  469. if(PopulateAuthMethods(wBuffer, cbSize))
  470. {
  471. for(int i=0;i<m_Index.size();i++)
  472. {
  473. if(m_Index[i]==lCurrentMethodIndex)
  474. {
  475. m_lCurrentMethodIndex=i;
  476. break;
  477. }
  478. }
  479. m_bIsInitialized=TRUE;
  480. bRtVal=TRUE;
  481. }
  482. }
  483. free(wBuffer);
  484. }
  485. }
  486. }
  487. RegCloseKey(hPop3Key);
  488. }
  489. }
  490. LeaveCriticalSection(&m_csVectorGuard);
  491. return bRtVal;
  492. }
  493. BOOL CAuthMethods::PopulateAuthMethods(WCHAR *wBuffer, DWORD cbSize)
  494. {
  495. //Parse the multi-string buffer
  496. DWORD dwSize=cbSize/sizeof(WCHAR);
  497. WCHAR *pStart, *pEnd;
  498. PAUTH_METHOD_INFO pAuthInfo=NULL;
  499. BOOL bRetVal=TRUE;
  500. if(NULL == wBuffer)
  501. {
  502. return FALSE;
  503. }
  504. if(0!=wBuffer[dwSize-1])
  505. {
  506. //Wrong format
  507. return FALSE;
  508. }
  509. pStart=wBuffer;
  510. pEnd=pStart+wcslen(pStart);
  511. while(pEnd<wBuffer+dwSize-1)
  512. {
  513. pAuthInfo=new(AUTH_METHOD_INFO);
  514. if(NULL == pAuthInfo)
  515. {
  516. bRetVal=FALSE;
  517. break;
  518. }
  519. ZeroMemory(pAuthInfo, sizeof(pAuthInfo));
  520. pAuthInfo->bstrGuid=SysAllocString(pStart);
  521. if(NULL == pAuthInfo->bstrGuid)
  522. {
  523. bRetVal=FALSE;
  524. break;
  525. }
  526. if(S_OK != CreateObj(pAuthInfo, &(pAuthInfo->pIAuthMethod)))
  527. {
  528. bRetVal=FALSE;
  529. break;
  530. }
  531. if(S_OK != pAuthInfo->pIAuthMethod->get_Name(&(pAuthInfo->bstrName)) )
  532. {
  533. bRetVal=FALSE;
  534. break;
  535. }
  536. m_AuthVector.push_back(pAuthInfo);
  537. if(SUCCEEDED(VerifyAuthMethod(pAuthInfo->bstrGuid)))
  538. {
  539. //Only show valid auth methods
  540. m_Index.push_back(m_AuthVector.size()-1);
  541. pAuthInfo->bIsValid=TRUE;
  542. }
  543. else
  544. {
  545. pAuthInfo->bIsValid=FALSE;
  546. }
  547. pStart=pEnd+1;
  548. pEnd=pStart+wcslen(pStart);
  549. }
  550. if(!bRetVal)
  551. {
  552. if(NULL !=pAuthInfo)
  553. {
  554. if(NULL!=pAuthInfo->pIAuthMethod)
  555. {
  556. pAuthInfo->pIAuthMethod->Release();
  557. }
  558. SysFreeString(pAuthInfo->bstrGuid);
  559. SysFreeString(pAuthInfo->bstrName);
  560. delete pAuthInfo;
  561. }
  562. CleanUp();
  563. }
  564. return bRetVal;
  565. }
  566. HRESULT CAuthMethods::CreateObj(PAUTH_METHOD_INFO pAuthInfo, IAuthMethod **ppVal)
  567. {
  568. HRESULT hr=S_OK;
  569. UUID uuid;
  570. if( ( NULL == pAuthInfo ) ||
  571. ( NULL == ppVal ) )
  572. {
  573. return E_POINTER;
  574. }
  575. if(pAuthInfo->bstrGuid == NULL)
  576. {
  577. return E_INVALIDARG;
  578. }
  579. if(RPC_S_OK != UuidFromString(pAuthInfo->bstrGuid, &uuid))
  580. {
  581. return E_INVALIDARG;
  582. }
  583. hr=CoCreateInstance(uuid,
  584. NULL,
  585. CLSCTX_INPROC_SERVER,
  586. IID_IAuthMethod,
  587. (LPVOID *)ppVal);
  588. return hr;
  589. }
  590. //The index here is the relative index exposed through public interface
  591. STDMETHODIMP CAuthMethods::VerifyCurrentAuthMethod(int iIndex)
  592. {
  593. HRESULT hr=E_FAIL;
  594. long lCount=0;
  595. if(! m_bIsInitialized)
  596. {
  597. if(!Initialize())
  598. {
  599. return E_FAIL;
  600. }
  601. }
  602. if( iIndex < 0 )
  603. {
  604. if(m_lCurrentMethodIndex < 0 )
  605. {
  606. return HRESULT_FROM_WIN32(ERROR_DS_AUTH_METHOD_NOT_SUPPORTED);
  607. }
  608. iIndex=m_lCurrentMethodIndex;
  609. }
  610. if( (NO_DOMAIN==m_lMachineRole) &&
  611. (0==_wcsicmp(m_AuthVector[m_Index[iIndex]]->bstrGuid, SZ_AUTH_ID_DOMAIN_AD)) )
  612. {
  613. return E_INVALIDARG;
  614. }
  615. if( (DOMAIN_CONTROLLER==m_lMachineRole) &&
  616. (0==_wcsicmp(m_AuthVector[m_Index[iIndex]]->bstrGuid, SZ_AUTH_ID_LOCAL_SAM)) )
  617. {
  618. return E_INVALIDARG;
  619. }
  620. if( 0 ==_wcsicmp(m_AuthVector[m_Index[iIndex]]->bstrGuid, SZ_AUTH_ID_MD5_HASH) )
  621. {
  622. // Set the SPA required reg key to 0
  623. RegSetSPARequired(0); //Don't care if the key does not exist
  624. }
  625. if( iIndex != m_lCurrentMethodIndex)
  626. {
  627. // Can not change Auth Method if there is a email domain
  628. CComPtr<IP3Config> spIConfig;
  629. CComPtr<IP3Domains> spIDomains;
  630. hr = CoCreateInstance( __uuidof( P3Config ), NULL, CLSCTX_ALL, __uuidof( IP3Config ),reinterpret_cast<LPVOID *>( &spIConfig ));
  631. if( S_OK == hr )
  632. {
  633. hr = spIConfig->put_MachineName( m_bstrServerName );
  634. if( S_OK== hr)
  635. {
  636. hr = spIConfig->get_Domains( &spIDomains );
  637. }
  638. }
  639. if( S_OK == hr )
  640. {
  641. hr = spIDomains->get_Count( &lCount );
  642. if ( S_OK == hr )
  643. {
  644. if(0==lCount)
  645. {
  646. return S_OK;
  647. }
  648. }
  649. }
  650. return STG_E_ACCESSDENIED;
  651. }
  652. return S_OK;
  653. }
  654. HRESULT CAuthMethods::SetMachineRole()
  655. {
  656. DSROLE_PRIMARY_DOMAIN_INFO_BASIC *pMachineRole=NULL;
  657. //Check the Role of the machine
  658. if( ERROR_SUCCESS==
  659. DsRoleGetPrimaryDomainInformation(
  660. m_bstrServerName,
  661. DsRolePrimaryDomainInfoBasic,
  662. (PBYTE *)(&pMachineRole)) )
  663. {
  664. switch(pMachineRole->MachineRole)
  665. {
  666. case DsRole_RoleStandaloneWorkstation:
  667. case DsRole_RoleStandaloneServer: m_lMachineRole=NO_DOMAIN;
  668. break;
  669. case DsRole_RoleMemberWorkstation:
  670. case DsRole_RoleMemberServer:m_lMachineRole=DOMAIN_NONE_DC;
  671. break;
  672. case DsRole_RoleBackupDomainController:
  673. case DsRole_RolePrimaryDomainController:m_lMachineRole=DOMAIN_CONTROLLER;
  674. break;
  675. }
  676. DsRoleFreeMemory(pMachineRole);
  677. pMachineRole=NULL;
  678. return S_OK;
  679. }
  680. return E_FAIL;
  681. }
  682. HRESULT CAuthMethods::VerifyAuthMethod(BSTR bstrGuid)
  683. {
  684. if(bstrGuid == NULL)
  685. {
  686. return E_POINTER;
  687. }
  688. if( (NO_DOMAIN==m_lMachineRole) &&
  689. (0==_wcsicmp(bstrGuid, SZ_AUTH_ID_DOMAIN_AD)) )
  690. {
  691. return E_FAIL;
  692. }
  693. if( (DOMAIN_CONTROLLER==m_lMachineRole) &&
  694. (0==_wcsicmp(bstrGuid, SZ_AUTH_ID_LOCAL_SAM)) )
  695. {
  696. return E_FAIL;
  697. }
  698. return S_OK;
  699. }