Source code of Windows XP (NT5)
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.

813 lines
32 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: dsUtil.h
  7. //
  8. // Contents: Utility functions for working with Active Directory
  9. //
  10. // History: 05-Sep-2000 JeffJon Created
  11. //
  12. //
  13. //--------------------------------------------------------------------------
  14. #ifndef _DSUTIL_H_
  15. #define _DSUTIL_H_
  16. //+--------------------------------------------------------------------------
  17. //
  18. // Class: CDSCmdCredentialObject
  19. //
  20. // Purpose: Object for maintaining username and an encrypted password
  21. //
  22. // History: 6-Sep-2000 JeffJon Created
  23. //
  24. //---------------------------------------------------------------------------
  25. class CDSCmdCredentialObject
  26. {
  27. public :
  28. //
  29. // Constructor
  30. //
  31. CDSCmdCredentialObject();
  32. //
  33. // Destructor
  34. //
  35. ~CDSCmdCredentialObject();
  36. //
  37. // Public accessor methods
  38. //
  39. PCWSTR GetUsername() const { return m_sbstrUsername; }
  40. HRESULT SetUsername(PCWSTR pszUsername);
  41. HRESULT GetPassword(PWSTR pszPassword, UINT* pnWCharCount) const;
  42. HRESULT SetPassword(PCWSTR pszPassword);
  43. bool UsingCredentials() const { return m_bUsingCredentials; }
  44. void SetUsingCredentials(const bool bUseCred) { m_bUsingCredentials = bUseCred; }
  45. private :
  46. //
  47. // Private data members
  48. //
  49. CComBSTR m_sbstrUsername;
  50. PWSTR m_pszPassword;
  51. bool m_bUsingCredentials;
  52. };
  53. typedef enum
  54. {
  55. DSCMD_LDAP_PROVIDER = 0,
  56. DSCMD_GC_PROVIDER
  57. } DSCMD_PROVIDER_TYPE;
  58. //+--------------------------------------------------------------------------
  59. //
  60. // Class: CDSCmdBasePathsInfo
  61. //
  62. // Purpose: Object for storing and retrieving the paths for the well
  63. // known naming contexts
  64. //
  65. // History: 6-Sep-2000 JeffJon Created
  66. //
  67. //---------------------------------------------------------------------------
  68. class CDSCmdBasePathsInfo
  69. {
  70. public:
  71. //
  72. // Constructor
  73. //
  74. CDSCmdBasePathsInfo();
  75. //
  76. // Destructor
  77. //
  78. ~CDSCmdBasePathsInfo();
  79. //
  80. // Public accessor methods
  81. //
  82. HRESULT InitializeFromName(const CDSCmdCredentialObject& refCredentialObject,
  83. PCWSTR pszServerOrDomain,
  84. bool bServerName = false);
  85. bool IsInitialized() const { return m_bInitialized; }
  86. CComBSTR GetProviderAndServerName() const { return m_sbstrProviderAndServerName; }
  87. CComBSTR GetGCProvider() const { return m_sbstrGCProvider; }
  88. CComBSTR GetServerName() const { return m_sbstrServerName; }
  89. IADs* GetRootDSE() const { return m_spRootDSE; }
  90. CComBSTR GetConfigurationNamingContext() const;
  91. CComBSTR GetSchemaNamingContext() const;
  92. CComBSTR GetDefaultNamingContext() const;
  93. //
  94. // Other helpful methods
  95. //
  96. void ComposePathFromDN(PCWSTR pszDN,
  97. CComBSTR& refsbstrPath,
  98. DSCMD_PROVIDER_TYPE nProviderType = DSCMD_LDAP_PROVIDER) const;
  99. HRESULT GetDomainMode(const CDSCmdCredentialObject& refCredObject,
  100. bool& bMixedMode) const;
  101. private:
  102. //
  103. // Private data members
  104. //
  105. bool m_bInitialized;
  106. CComBSTR m_sbstrProviderAndServerName;
  107. CComBSTR m_sbstrGCProvider;
  108. CComBSTR m_sbstrServerName;
  109. mutable bool m_bModeInitialized;
  110. mutable bool m_bDomainMode;
  111. mutable CComBSTR m_sbstrConfigNamingContext;
  112. mutable CComBSTR m_sbstrSchemaNamingContext;
  113. mutable CComBSTR m_sbstrDefaultNamingContext;
  114. CComPtr<IADs> m_spRootDSE;
  115. };
  116. //////////////////////////////////////////////////////////////////////////////////////
  117. //+--------------------------------------------------------------------------
  118. //
  119. // Function: DSCmdOpenObject
  120. //
  121. // Synopsis: A wrapper around ADsOpenObject
  122. //
  123. // Arguments: [refCredentialObject - IN] : a reference to a credential management object
  124. // [pszPath - IN] : a pointer to a NULL terminated wide character
  125. // string that contains the ADSI path of the
  126. // object to connect to
  127. // [refIID - IN] : the interface ID of the interface to return
  128. // [ppObject - OUT] : a pointer which is to receive the interface pointer
  129. // [bBindToServer - IN] : true if the path contains a server name,
  130. // false otherwise
  131. //
  132. // Returns: HRESULT : S_OK if everything succeeded
  133. // Anything else is a failure code from an ADSI call
  134. //
  135. // History: 06-Sep-2000 JeffJon Created
  136. //
  137. //---------------------------------------------------------------------------
  138. HRESULT DSCmdOpenObject(const CDSCmdCredentialObject& refCredentialObject,
  139. PCWSTR pszPath,
  140. REFIID refIID,
  141. void** ppObject,
  142. bool bBindToServer);
  143. //+--------------------------------------------------------------------------
  144. //
  145. // Function: GetErrorMessage
  146. //
  147. // Synopsis: Retrieves the error message associated with the HRESULT by
  148. // using FormatMessage
  149. //
  150. // Arguments: [hr - IN] : HRESULT for which the error
  151. // message is to be retrieved
  152. // [sbstrErrorMessage - OUT] : Receives the error message
  153. //
  154. // Returns: bool : true if the message was formatted properly
  155. // false otherwise
  156. //
  157. // History: 11-Sep-2000 JeffJon Created
  158. //
  159. //---------------------------------------------------------------------------
  160. bool GetErrorMessage(HRESULT hr, CComBSTR& sbstrErrorMessage);
  161. //+--------------------------------------------------------------------------
  162. //
  163. // Function: DisplayErrorMessage
  164. //
  165. // Synopsis: Displays the error message retrieved from GetErrorMessage
  166. // to stderr. If GetErrorMessage fails, it displays the error
  167. // code of the HRESULT
  168. //
  169. // Arguments: [pszCommand - IN]: the name of the command line executable
  170. // [pszName - IN] : the name passed in as the target of the operation
  171. // [hr - IN] : HRESULT for which the error
  172. // message is to be retrieved
  173. // [pszMessage - IN]: string of an additional message to be displayed
  174. // at the end
  175. //
  176. // Returns: bool : true if the message was formatted and displayed properly
  177. // false otherwise
  178. //
  179. // History: 11-Sep-2000 JeffJon Created
  180. //
  181. //---------------------------------------------------------------------------
  182. bool DisplayErrorMessage(PCWSTR pszCommand,
  183. PCWSTR pszName,
  184. HRESULT hr,
  185. PCWSTR pszMessage = NULL);
  186. //+--------------------------------------------------------------------------
  187. //
  188. // Function: DisplayErrorMessage
  189. //
  190. // Synopsis: Displays the error message retrieved from GetErrorMessage
  191. // to stderr. If GetErrorMessage fails, it displays the error
  192. // code of the HRESULT
  193. //
  194. // Arguments: [pszCommand - IN]: the name of the command line executable
  195. // [pszName - IN] : the name passed in as the target of the operation
  196. // [hr - IN] : HRESULT for which the error
  197. // message is to be retrieved
  198. // [nStringID - IN] : Resource ID an additional message to be displayed
  199. // at the end
  200. //
  201. // Returns: bool : true if the message was formatted and displayed properly
  202. // false otherwise
  203. //
  204. // History: 11-Sep-2000 JeffJon Created
  205. //
  206. //---------------------------------------------------------------------------
  207. bool DisplayErrorMessage(PCWSTR pszCommand,
  208. PCWSTR pszName,
  209. HRESULT hr,
  210. UINT nStringID);
  211. //+--------------------------------------------------------------------------
  212. //
  213. // Function: DisplaySuccessMessage
  214. //
  215. // Synopsis: Displays a success message for the command
  216. //
  217. // Arguments: [pszCommand - IN]: the name of the command line executable
  218. // [pszName - IN] : the name passed in as the target of the operation
  219. //
  220. // Returns: bool : true if the message was formatted and displayed properly
  221. // false otherwise
  222. //
  223. // History: 11-Sep-2000 JeffJon Created
  224. //
  225. //---------------------------------------------------------------------------
  226. bool DisplaySuccessMessage(PCWSTR pszCommand,
  227. PCWSTR pszName);
  228. //+--------------------------------------------------------------------------
  229. //
  230. // Function: WriteStringIDToStandardOut
  231. //
  232. // Synopsis: Loads the String Resource and displays on Standardout
  233. //
  234. // Arguments: nStringID : Resource ID
  235. // Returns: bool : true if the message was formatted and displayed properly
  236. // false otherwise
  237. //
  238. // History: 11-Sep-2000 hiteshr Created
  239. //
  240. //---------------------------------------------------------------------------
  241. bool WriteStringIDToStandardOut(UINT nStringID);
  242. /////////////////////////////////////////////////////////////////////////////////////////
  243. //
  244. // Forward declarations
  245. //
  246. struct _DSAttributeTableEntry;
  247. //+--------------------------------------------------------------------------
  248. //
  249. // Struct: _DSObjectTableEntry
  250. //
  251. // Purpose: Definition of a table entry that describes what attributes
  252. // are exposed on an specific object class
  253. //
  254. // History: 6-Sep-2000 JeffJon Created
  255. //
  256. //---------------------------------------------------------------------------
  257. typedef struct _DSObjectTableEntry
  258. {
  259. //
  260. // The objectClass of the object to be created or modified
  261. //
  262. PCWSTR pszObjectClass;
  263. //
  264. // The command line string used to determine the object class
  265. // This is not always identical to pszObjectClass
  266. //
  267. PCWSTR pszCommandLineObjectType;
  268. //
  269. // The table to merge with the common switches for the parser
  270. //
  271. ARG_RECORD* pParserTable;
  272. //
  273. // The ID of the Usage help text for this
  274. //
  275. UINT nUsageID;
  276. //
  277. // A count of the number of attributes in the table above
  278. //
  279. DWORD dwAttributeCount;
  280. //
  281. // A pointer to a table of attributes that can be modified or set on this class
  282. //
  283. _DSAttributeTableEntry** pAttributeTable;
  284. // Some sort of creation function
  285. } DSOBJECTTABLEENTRY, *PDSOBJECTTABLEENTRY;
  286. //+-------------------------------------------------------------------------
  287. //
  288. // Type: PATTRIBUTEEVALFUNC
  289. //
  290. // Synopsis: The definition of a function that prepares the command line
  291. // string value to be set in the DS.
  292. //
  293. // Note: *ppAttr should be set to NULL if this function does not need
  294. // to create a new unique ADS_ATTR_INFO structure in the array
  295. // to be set on the object. For instance, there are many bits
  296. // in the user account control that are represented by different
  297. // command line flags but we really only need one entry for the
  298. // userAccountControl attribute.
  299. //
  300. // Returns: S_OK if the pAttr members were successfully set.
  301. // S_FALSE if the function failed but displayed its own error message.
  302. // If the return value is S_FALSE then the function should call
  303. // SetLastError() with the error code.
  304. // Otherwise the pAttr info will not be used when making
  305. // the modifications to the object and an error will be reported
  306. //
  307. // History: 08-Sep-2000 JeffJon Created
  308. //
  309. //---------------------------------------------------------------------------
  310. typedef HRESULT (*PATTRIBUTEEVALFUNC)(PCWSTR pszPath,
  311. const CDSCmdBasePathsInfo& refBasePathsInfo,
  312. const CDSCmdCredentialObject& refCredentialObject,
  313. const PDSOBJECTTABLEENTRY pObjectEntry,
  314. const ARG_RECORD& argRecord,
  315. DWORD dwAttributeIdx,
  316. PADS_ATTR_INFO* ppAttr);
  317. //+--------------------------------------------------------------------------
  318. //
  319. // Flags for the _DSAttributeDescription and _DSAttributeTableEntry
  320. // struct dwFlags field
  321. //
  322. //---------------------------------------------------------------------------
  323. #define DS_ATTRIBUTE_DIRTY 0x00000001
  324. #define DS_ATTRIBUTE_READ 0x00000002
  325. #define DS_ATTRIBUTE_ONCREATE 0x00000004
  326. #define DS_ATTRIBUTE_POSTCREATE 0x00000008
  327. #define DS_ATTRIBUTE_REQUIRED 0x00000010
  328. #define DS_ATTRIBUTE_NOT_REUSABLE 0x00000020
  329. //+--------------------------------------------------------------------------
  330. //
  331. // Struct: _DSAttributeDescription
  332. //
  333. // Purpose: Definition of a table entry that describes an attribute
  334. // This was split out from _DSAttributeTableEntry so that
  335. // more than one entry could point to the same attribute.
  336. // For instance, the userAccountControl bits are separate
  337. // command line flags but all use the same attribute. This
  338. // way we only need to read the attribute once and set it once.
  339. //
  340. // History: 13-Sep-2000 JeffJon Created
  341. //
  342. //---------------------------------------------------------------------------
  343. typedef struct _DSAttributeDescription
  344. {
  345. //
  346. // The ADS_ATTR_INFO struct that defines how this attribute will be set
  347. //
  348. ADS_ATTR_INFO adsAttrInfo;
  349. //
  350. // Flags that are used to determine how and when the attribute can be set,
  351. // if the adsAttrInfo has been retrieved and/or set.
  352. // For instance, group membership can only be set after the user object is
  353. // created
  354. //
  355. DWORD dwFlags;
  356. } DSATTRIBUTEDESCRIPTION, *PDSATTRIBUTEDESCRIPTION;
  357. //+--------------------------------------------------------------------------
  358. //
  359. // Struct: _DSAttributeTableEntry
  360. //
  361. // Purpose: Definition of a table entry that describes an attribute
  362. //
  363. // History: 6-Sep-2000 JeffJon Created
  364. //
  365. //---------------------------------------------------------------------------
  366. typedef struct _DSAttributeTableEntry
  367. {
  368. //
  369. // The name of the attribute
  370. //
  371. PWSTR pszName;
  372. //
  373. // The unique identifier for this attribute that cooresponds to
  374. // the command line switch
  375. //
  376. UINT nAttributeID;
  377. //
  378. // Flags that represent when this attribute can be set in relation to
  379. // the objects creation
  380. //
  381. DWORD dwFlags;
  382. //
  383. // Pointer to the description of the attribute
  384. //
  385. PDSATTRIBUTEDESCRIPTION pAttrDesc;
  386. //
  387. // A function that can evaluate the value string passed in and make
  388. // it ready for setting on the object
  389. //
  390. PATTRIBUTEEVALFUNC pEvalFunc;
  391. //
  392. // Undefined data that is static and specific for the entry
  393. //
  394. void* pVoid;
  395. } DSATTRIBUTETABLEENTRY, *PDSATTRIBUTETABLEENTRY;
  396. //+--------------------------------------------------------------------------
  397. //
  398. // Function: ReadGroupType
  399. //
  400. // Synopsis: Reads the group type from the group specified by the given DN
  401. //
  402. // Arguments: [pszDN - IN] : pointer to a string containing the DN
  403. // to the object being modified
  404. // [refBasePathsInfo - IN] : reference to an instance of the
  405. // CDSCmdBasePathsInfo class
  406. // [refCredentialObject - IN] : reference to an instance of the
  407. // CDSCmdCredentialObject class
  408. // [plType - OUT] : returns the currect group type
  409. //
  410. // Returns: HRESULT : S_OK if everything succeeded
  411. // Otherwise an ADSI failure code
  412. //
  413. // History: 18-Sep-2000 JeffJon Created
  414. //
  415. //---------------------------------------------------------------------------
  416. HRESULT ReadGroupType(PCWSTR pszDN,
  417. const CDSCmdBasePathsInfo& refBasePathsInfo,
  418. const CDSCmdCredentialObject& refCredentialObject,
  419. long* plType);
  420. //+--------------------------------------------------------------------------
  421. // Function to be used in the attribute table for evaluating the command line
  422. // strings
  423. //---------------------------------------------------------------------------
  424. HRESULT FillAttrInfoFromObjectEntry(PCWSTR pszDN,
  425. const CDSCmdBasePathsInfo& refBasePathsInfo,
  426. const CDSCmdCredentialObject& refCredentialObject,
  427. const PDSOBJECTTABLEENTRY pObjectEntry,
  428. const ARG_RECORD& argRecord,
  429. DWORD dwAttributeIdx,
  430. PADS_ATTR_INFO* ppAttr);
  431. HRESULT ResetUserPassword(PCWSTR pszDN,
  432. const CDSCmdBasePathsInfo& refBasePathsInfo,
  433. const CDSCmdCredentialObject& refCredentialObject,
  434. const PDSOBJECTTABLEENTRY pObjectEntry,
  435. const ARG_RECORD& argRecord,
  436. DWORD dwAttributeIdx,
  437. PADS_ATTR_INFO* ppAttr);
  438. HRESULT ResetComputerAccount(PCWSTR pszDN,
  439. const CDSCmdBasePathsInfo& refBasePathsInfo,
  440. const CDSCmdCredentialObject& refCredentialObject,
  441. const PDSOBJECTTABLEENTRY pObjectEntry,
  442. const ARG_RECORD& argRecord,
  443. DWORD dwAttributeIdx,
  444. PADS_ATTR_INFO* ppAttr);
  445. HRESULT DisableAccount(PCWSTR pszDN,
  446. const CDSCmdBasePathsInfo& refBasePathsInfo,
  447. const CDSCmdCredentialObject& refCredentialObject,
  448. const PDSOBJECTTABLEENTRY pObjectEntry,
  449. const ARG_RECORD& argRecord,
  450. DWORD dwAttributeIdx,
  451. PADS_ATTR_INFO* ppAttr);
  452. HRESULT SetMustChangePwd(PCWSTR pszDN,
  453. const CDSCmdBasePathsInfo& refBasePathsInfo,
  454. const CDSCmdCredentialObject& refCredentialObject,
  455. const PDSOBJECTTABLEENTRY pObjectEntry,
  456. const ARG_RECORD& argRecord,
  457. DWORD dwAttributeIdx,
  458. PADS_ATTR_INFO* ppAttr);
  459. HRESULT ChangeMustChangePwd(PCWSTR pszDN,
  460. const CDSCmdBasePathsInfo& refBasePathsInfo,
  461. const CDSCmdCredentialObject& refCredentialObject,
  462. const PDSOBJECTTABLEENTRY pObjectEntry,
  463. const ARG_RECORD& argRecord,
  464. DWORD dwAttributeIdx,
  465. PADS_ATTR_INFO* ppAttr);
  466. HRESULT PwdNeverExpires(PCWSTR pszDN,
  467. const CDSCmdBasePathsInfo& refBasePathsInfo,
  468. const CDSCmdCredentialObject& refCredentialObject,
  469. const PDSOBJECTTABLEENTRY pObjectEntry,
  470. const ARG_RECORD& argRecord,
  471. DWORD dwAttributeIdx,
  472. PADS_ATTR_INFO* ppAttr);
  473. HRESULT ReversiblePwd(PCWSTR pszDN,
  474. const CDSCmdBasePathsInfo& refBasePathsInfo,
  475. const CDSCmdCredentialObject& refCredentialObject,
  476. const PDSOBJECTTABLEENTRY pObjectEntry,
  477. const ARG_RECORD& argRecord,
  478. DWORD dwAttributeIdx,
  479. PADS_ATTR_INFO* ppAttr);
  480. HRESULT AccountExpires(PCWSTR pszDN,
  481. const CDSCmdBasePathsInfo& refBasePathsInfo,
  482. const CDSCmdCredentialObject& refCredentialObject,
  483. const PDSOBJECTTABLEENTRY pObjectEntry,
  484. const ARG_RECORD& argRecord,
  485. DWORD dwAttributeIdx,
  486. PADS_ATTR_INFO* ppAttr);
  487. HRESULT SetCanChangePassword(PCWSTR pszDN,
  488. const CDSCmdBasePathsInfo& refBasePathsInfo,
  489. const CDSCmdCredentialObject& refCredentialObject,
  490. const PDSOBJECTTABLEENTRY pObjectEntry,
  491. const ARG_RECORD& argRecord,
  492. DWORD dwAttributeIdx,
  493. PADS_ATTR_INFO* ppAttr);
  494. HRESULT ChangeCanChangePassword(PCWSTR pszDN,
  495. const CDSCmdBasePathsInfo& refBasePathsInfo,
  496. const CDSCmdCredentialObject& refCredentialObject,
  497. const PDSOBJECTTABLEENTRY pObjectEntry,
  498. const ARG_RECORD& argRecord,
  499. DWORD dwAttributeIdx,
  500. PADS_ATTR_INFO* ppAttr);
  501. HRESULT SetGroupScope(PCWSTR pszDN,
  502. const CDSCmdBasePathsInfo& refBasePathsInfo,
  503. const CDSCmdCredentialObject& refCredentialObject,
  504. const PDSOBJECTTABLEENTRY pObjectEntry,
  505. const ARG_RECORD& argRecord,
  506. DWORD dwAttributeIdx,
  507. PADS_ATTR_INFO* ppAttr);
  508. HRESULT ChangeGroupScope(PCWSTR pszDN,
  509. const CDSCmdBasePathsInfo& refBasePathsInfo,
  510. const CDSCmdCredentialObject& refCredentialObject,
  511. const PDSOBJECTTABLEENTRY pObjectEntry,
  512. const ARG_RECORD& argRecord,
  513. DWORD dwAttributeIdx,
  514. PADS_ATTR_INFO* ppAttr);
  515. HRESULT SetGroupSecurity(PCWSTR pszDN,
  516. const CDSCmdBasePathsInfo& refBasePathsInfo,
  517. const CDSCmdCredentialObject& refCredentialObject,
  518. const PDSOBJECTTABLEENTRY pObjectEntry,
  519. const ARG_RECORD& argRecord,
  520. DWORD dwAttributeIdx,
  521. PADS_ATTR_INFO* ppAttr);
  522. HRESULT ChangeGroupSecurity(PCWSTR pszDN,
  523. const CDSCmdBasePathsInfo& refBasePathsInfo,
  524. const CDSCmdCredentialObject& refCredentialObject,
  525. const PDSOBJECTTABLEENTRY pObjectEntry,
  526. const ARG_RECORD& argRecord,
  527. DWORD dwAttributeIdx,
  528. PADS_ATTR_INFO* ppAttr);
  529. HRESULT ModifyGroupMembers(PCWSTR pszDN,
  530. const CDSCmdBasePathsInfo& refBasePathsInfo,
  531. const CDSCmdCredentialObject& refCredentialObject,
  532. const PDSOBJECTTABLEENTRY pObjectEntry,
  533. const ARG_RECORD& argRecord,
  534. DWORD dwAttributeIdx,
  535. PADS_ATTR_INFO* ppAttr);
  536. HRESULT RemoveGroupMembers(PCWSTR pszDN,
  537. const CDSCmdBasePathsInfo& refBasePathsInfo,
  538. const CDSCmdCredentialObject& refCredentialObject,
  539. const PDSOBJECTTABLEENTRY pObjectEntry,
  540. const ARG_RECORD& argRecord,
  541. DWORD dwAttributeIdx,
  542. PADS_ATTR_INFO* ppAttr);
  543. HRESULT MakeMemberOf(PCWSTR pszDN,
  544. const CDSCmdBasePathsInfo& refBasePathsInfo,
  545. const CDSCmdCredentialObject& refCredentialObject,
  546. const PDSOBJECTTABLEENTRY pObjectEntry,
  547. const ARG_RECORD& argRecord,
  548. DWORD dwAttributeIdx,
  549. PADS_ATTR_INFO* ppAttr);
  550. HRESULT BuildComputerSAMName(PCWSTR pszDN,
  551. const CDSCmdBasePathsInfo& refBasePathsInfo,
  552. const CDSCmdCredentialObject& refCredentialObject,
  553. const PDSOBJECTTABLEENTRY pObjectEntry,
  554. const ARG_RECORD& argRecord,
  555. DWORD dwAttributeIdx,
  556. PADS_ATTR_INFO* ppAttr);
  557. HRESULT BuildGroupSAMName(PCWSTR pszDN,
  558. const CDSCmdBasePathsInfo& refBasePathsInfo,
  559. const CDSCmdCredentialObject& refCredentialObject,
  560. const PDSOBJECTTABLEENTRY pObjectEntry,
  561. const ARG_RECORD& argRecord,
  562. DWORD dwAttributeIdx,
  563. PADS_ATTR_INFO* ppAttr);
  564. HRESULT FillAttrInfoFromObjectEntryExpandUsername(PCWSTR pszDN,
  565. const CDSCmdBasePathsInfo& refBasePathsInfo,
  566. const CDSCmdCredentialObject& refCredentialObject,
  567. const PDSOBJECTTABLEENTRY pObjectEntry,
  568. const ARG_RECORD& argRecord,
  569. DWORD dwAttributeIdx,
  570. PADS_ATTR_INFO* ppAttr);
  571. HRESULT SetComputerAccountType(PCWSTR pszDN,
  572. const CDSCmdBasePathsInfo& refBasePathsInfo,
  573. const CDSCmdCredentialObject& refCredentialObject,
  574. const PDSOBJECTTABLEENTRY pObjectEntry,
  575. const ARG_RECORD& argRecord,
  576. DWORD dwAttributeIdx,
  577. PADS_ATTR_INFO* ppAttr);
  578. HRESULT SetIsGC(PCWSTR pszDN,
  579. const CDSCmdBasePathsInfo& refBasePathsInfo,
  580. const CDSCmdCredentialObject& refCredentialObject,
  581. const PDSOBJECTTABLEENTRY pObjectEntry,
  582. const ARG_RECORD& argRecord,
  583. DWORD dwAttributeIdx,
  584. PADS_ATTR_INFO* ppAttr);
  585. //+--------------------------------------------------------------------------
  586. //
  587. // Function: EvaluateMustChangePassword
  588. //
  589. // Synopsis:
  590. //
  591. // Arguments: [pszDN - IN] : DN of the object to check
  592. // [refBasePathsInfo - IN] : reference to the base paths info
  593. // [refCredentialObject - IN] : reference to the credential manangement object
  594. // [bMustChangePassword - OUT] : true if the user must change their
  595. // password at next logon, false otherwise
  596. //
  597. // Returns: HRESULT : S_OK if everything succeeded
  598. // Otherwise an ADSI failure code
  599. //
  600. // History: 27-Oct-2000 JeffJon Created
  601. //
  602. //---------------------------------------------------------------------------
  603. HRESULT EvaluateMustChangePassword(PCWSTR pszDN,
  604. const CDSCmdBasePathsInfo& refBasePathsInfo,
  605. const CDSCmdCredentialObject& refCredentialObject,
  606. bool& bMustChangePassword);
  607. //+--------------------------------------------------------------------------
  608. //
  609. // Function: EvaluateCanChangePasswordAces
  610. //
  611. // Synopsis: Looks for explicit entries in the ACL to see if the user can
  612. // change their password
  613. //
  614. // Arguments: [pszDN - IN] : DN of the object to check
  615. // [refBasePathsInfo - IN] : reference to the base paths info
  616. // [refCredentialObject - IN] : reference to the credential manangement object
  617. // [bCanChangePassword - OUT] : false if there are explicit entries
  618. // that keep the user from changing their
  619. // password. true otherwise.
  620. //
  621. // Returns: HRESULT : S_OK if everything succeeded
  622. // Otherwise an ADSI failure code
  623. //
  624. // History: 27-Oct-2000 JeffJon Created
  625. //
  626. //---------------------------------------------------------------------------
  627. HRESULT EvaluateCanChangePasswordAces(PCWSTR pszDN,
  628. const CDSCmdBasePathsInfo& refBasePathsInfo,
  629. const CDSCmdCredentialObject& refCredentialObject,
  630. bool& bCanChangePassword);
  631. //+--------------------------------------------------------------------------
  632. //
  633. // Enumeration: FSMO_TYPE
  634. //
  635. // Synopsis: The types of FSMO owners
  636. //
  637. //---------------------------------------------------------------------------
  638. enum FSMO_TYPE
  639. {
  640. SCHEMA_FSMO,
  641. RID_POOL_FSMO,
  642. PDC_FSMO,
  643. INFRASTUCTURE_FSMO,
  644. DOMAIN_NAMING_FSMO,
  645. };
  646. //+--------------------------------------------------------------------------
  647. //
  648. // Function: BindToFSMOHolder
  649. //
  650. // Synopsis: Binds to the appropriate object which can be used to find a
  651. // particular FSMO owner
  652. //
  653. // Arguments: [refBasePathsInfo - IN] : reference to the base paths info object
  654. // [refCredObject - IN] : reference to the credential management object
  655. // [fsmoType - IN] : type of the FSMO we are searching for
  656. // [refspIADs - OUT] : interface to the object that will be
  657. // used to start a search for the FSMO owner
  658. //
  659. // Returns: HRESULT : S_OK if everything succeeded
  660. // Otherwise an ADSI failure code
  661. //
  662. // History: 13-Dec-2000 JeffJon Created
  663. //
  664. //---------------------------------------------------------------------------
  665. HRESULT BindToFSMOHolder(IN const CDSCmdBasePathsInfo& refBasePathsInfo,
  666. IN const CDSCmdCredentialObject& refCredObject,
  667. IN FSMO_TYPE fsmoType,
  668. OUT CComPtr<IADs>& refspIADs);
  669. //+--------------------------------------------------------------------------
  670. //
  671. // Function: FindFSMOOwner
  672. //
  673. // Synopsis:
  674. //
  675. // Arguments: [refBasePathsInfo - IN] : reference to the base paths info object
  676. // [refCredObject - IN] : reference to the credential management object
  677. // [fsmoType - IN] : type of the FSMO we are searching for
  678. // [refspIADs - OUT] : interface to the object that will be
  679. // used to start a search for the FSMO owner
  680. //
  681. // Returns: HRESULT : S_OK if everything succeeded
  682. // Otherwise an ADSI failure code
  683. //
  684. // History: 13-Dec-2000 JeffJon Created
  685. //
  686. //---------------------------------------------------------------------------
  687. HRESULT FindFSMOOwner(IN const CDSCmdBasePathsInfo& refBasePathsInfo,
  688. IN const CDSCmdCredentialObject& refCredObject,
  689. IN FSMO_TYPE fsmoType,
  690. OUT CComBSTR& refsbstrServer);
  691. //+--------------------------------------------------------------------------
  692. //
  693. // Function: ValidateAndModifySAMName
  694. //
  695. // Synopsis: Looks for any illegal characters in the SamAccountName and
  696. // converts them to the replacementChar
  697. //
  698. // Arguments: [pszSAMName - IN/OUT] : pointer to a string that contains the SamAccountName
  699. // illegal characters will be replaced
  700. // [pszInvalidChars - IN] : string containing the illegal characters
  701. //
  702. // Returns: HRESULT : S_OK if the name was valid and no characters had to be replaced
  703. // S_FALSE if the name contained invalid characters that were replaced
  704. // E_INVALIDARG
  705. //
  706. // History: 21-Feb-2001 JeffJon Created
  707. //
  708. //---------------------------------------------------------------------------
  709. #define INVALID_NETBIOS_AND_ACCOUNT_NAME_CHARS_WITH_AT ILLEGAL_FAT_CHARS L".@"
  710. HRESULT ValidateAndModifySAMName(PWSTR pszSAMName,
  711. PCWSTR pszInvalidChars);
  712. //+--------------------------------------------------------------------------
  713. //
  714. // Class: GetOutputDN
  715. //
  716. // Purpose: Converts an ADSI-escaped DN to one with DSCMD input escaping.
  717. // This way, the output DN can be piped as input to another
  718. // DSCMD command.
  719. //
  720. // History: 08-May-2001 JonN Created
  721. //
  722. //---------------------------------------------------------------------------
  723. HRESULT GetOutputDN( OUT BSTR* pbstrOut, IN PCWSTR pszIn );
  724. #endif //_DSUTIL_H_