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.

790 lines
23 KiB

  1. #include "main.h"
  2. #include <nwcalls.h>
  3. #include <nwnet.h>
  4. #include <nwlocale.h>
  5. #include "typedef.h"
  6. DWORD LoadNetwareDLLs();
  7. PF_NWCallsInit pfNWCallsInit = NULL;
  8. PF_NWFreeUnicodeTables pfNWFreeUnicodeTables= NULL;
  9. PF_NWInitUnicodeTables pfNWInitUnicodeTables= NULL;
  10. PF_NWLlocaleconv pfNWLlocaleconv= NULL;
  11. PF_NWDSFreeContext pfNWDSFreeContext= NULL;
  12. PF_NWDSFreeBuf pfNWDSFreeBuf= NULL;
  13. PF_NWDSLogout pfNWDSLogout= NULL;
  14. PF_NWDSGetAttrDef pfNWDSGetAttrDef= NULL;
  15. PF_NWDSGetAttrCount pfNWDSGetAttrCount= NULL;
  16. PF_NWDSReadAttrDef pfNWDSReadAttrDef= NULL;
  17. PF_NWDSPutAttrName pfNWDSPutAttrName= NULL;
  18. PF_NWDSInitBuf pfNWDSInitBuf= NULL;
  19. PF_NWDSAllocBuf pfNWDSAllocBuf= NULL;
  20. PF_NWDSLogin pfNWDSLogin= NULL;
  21. PF_NWDSSetContext pfNWDSSetContext= NULL;
  22. PF_NWDSGetContext pfNWDSGetContext= NULL;
  23. PF_NWIsDSAuthenticated pfNWIsDSAuthenticated= NULL;
  24. PF_NWDSCreateContext pfNWDSCreateContext= NULL;
  25. PF_NWDSModifyClassDef pfNWDSModifyClassDef = NULL;
  26. PF_NWDSDefineAttr pfNWDSDefineAttr = NULL;
  27. HINSTANCE calwin32LibraryHandle = NULL;
  28. HINSTANCE locwin32LibraryHandle = NULL;
  29. HINSTANCE netwin32LibraryHandle = NULL;
  30. DWORD Client32CheckSchemaExtension(
  31. PWSTR szServer,
  32. PWSTR szContext,
  33. PWSTR szUser,
  34. PWSTR szPasswd,
  35. BOOL *pfExtended
  36. )
  37. {
  38. NWDSContextHandle context = NULL;
  39. pBuf_T pInBuf = NULL;
  40. pBuf_T pOutBuf = NULL;
  41. BOOL fFreeUnicodeTable = FALSE;
  42. BOOL fLoggedIn= FALSE;
  43. BOOL fLogout = TRUE;
  44. nint32 lIterationHandle;
  45. Attr_Info_T attrInfo;
  46. NWDSCCODE ccode;
  47. nuint32 luTotalAttr;
  48. nstr8 strAttrName[MAX_SCHEMA_NAME_CHARS];
  49. nuint i;
  50. LCONV lConvInfo;
  51. nstr8 treeName[MAX_DN_CHARS+1];
  52. nstr8 strName[MAX_DN_CHARS+1];
  53. BOOL fSchemaExtended = FALSE;
  54. DWORD WinError;
  55. PSTR pszServer = NULL;
  56. PSTR pszContext = NULL;
  57. PSTR pszUser = NULL;
  58. PSTR pszPasswd = NULL;
  59. //
  60. // We only check server and extended because they are the only must-have
  61. // parameters
  62. //
  63. if (!(szServer && pfExtended)) {
  64. ERR(("Invalid parameters.\n"));
  65. WinError = ERROR_INVALID_PARAMETER;
  66. BAIL();
  67. }
  68. //
  69. // Basic initialization
  70. //
  71. WinError = LoadNetwareDLLs();
  72. if (WinError) {
  73. BAIL();
  74. }
  75. ccode = pfNWCallsInit(NULL,NULL);
  76. if (ccode) {
  77. ERR(("NWCallsInit returned %X\n", ccode));
  78. BAIL();
  79. }
  80. pfNWLlocaleconv(&lConvInfo);
  81. ccode = pfNWInitUnicodeTables(lConvInfo.country_id,
  82. lConvInfo.code_page);
  83. if (ccode) {
  84. ERR(("NWInitUnicodeTables returned %X\n", ccode));
  85. BAIL();
  86. }
  87. fFreeUnicodeTable = TRUE;
  88. context = pfNWDSCreateContext();
  89. if (context == (NWDSContextHandle)ERR_CONTEXT_CREATION) {
  90. ERR(("NWDSCreateContext failed\n"));
  91. BAIL();
  92. }
  93. pszServer = AllocateAnsiString(szServer);
  94. if (pszServer == NULL) {
  95. WinError = ERROR_NO_SYSTEM_RESOURCES;
  96. BAIL();
  97. }
  98. if (szContext == NULL) {
  99. goto doit;
  100. }
  101. pszContext = AllocateAnsiString(szContext);
  102. if (pszContext == NULL) {
  103. WinError = ERROR_NO_SYSTEM_RESOURCES;
  104. BAIL();
  105. }
  106. pszUser = AllocateAnsiString(szUser);
  107. if (pszUser == NULL) {
  108. WinError = ERROR_NO_SYSTEM_RESOURCES;
  109. BAIL();
  110. }
  111. pszPasswd = AllocateAnsiString(szPasswd);
  112. if (pszPasswd == NULL) {
  113. WinError = ERROR_NO_SYSTEM_RESOURCES;
  114. BAIL();
  115. }
  116. if(!pfNWIsDSAuthenticated()) {
  117. DEBUGOUT(("The system is not authenticated.\n"));
  118. }
  119. else {
  120. DEBUGOUT(("The system has been authenticated already\n"));
  121. //
  122. // Get Current tree's name
  123. //
  124. ccode = pfNWDSGetContext(context, DCK_TREE_NAME, &treeName);
  125. if(ccode) {
  126. ERR(("Get context returned %X\n", ccode));
  127. BAIL();
  128. }
  129. DEBUGOUT(("Current Tree is %s.\n",treeName));
  130. //
  131. // Get current context's name
  132. //
  133. ccode = pfNWDSGetContext(context, DCK_NAME_CONTEXT, &strName);
  134. if(ccode) {
  135. ERR(("\nGet context returned %X", ccode));
  136. BAIL();
  137. }
  138. DEBUGOUT(("Current Context is %s.\n",strName));
  139. //
  140. // If the current tree and context is the same as the desired tree
  141. // and context, we do not need to logout. Because that would blow out
  142. // the connection.
  143. //
  144. if ((_stricmp(treeName,pszServer) == 0) &&
  145. (_stricmp(strName,pszContext) == 0)) {
  146. DEBUGOUT(("Will not logout.\n",strName));
  147. fLogout = FALSE;
  148. }
  149. }
  150. //
  151. // Set context to another tree
  152. //
  153. ccode = pfNWDSSetContext(context,
  154. DCK_TREE_NAME,
  155. pszServer
  156. );
  157. if(ccode) {
  158. ERR(("\nSet context returned %X", ccode));
  159. BAIL();
  160. }
  161. //
  162. // Set context to another context
  163. //
  164. ccode = pfNWDSSetContext(
  165. context,
  166. DCK_NAME_CONTEXT,
  167. pszContext
  168. );
  169. if(ccode) {
  170. ERR(("\nSet context returned %X", ccode));
  171. BAIL();
  172. }
  173. //
  174. // Get Current tree's name
  175. //
  176. ccode = pfNWDSGetContext(context, DCK_TREE_NAME, &treeName);
  177. if(ccode) {
  178. ERR(("\nGet context returned %X", ccode));
  179. BAIL();
  180. }
  181. DEBUGOUT(("Current tree is %s.\n",treeName));
  182. ccode = pfNWDSGetContext(context, DCK_NAME_CONTEXT, &strName);
  183. if(ccode) {
  184. ERR(("\nGet context returned %X", ccode));
  185. BAIL();
  186. }
  187. DEBUGOUT(("Current conext is now %s.\n",strName));
  188. //
  189. // Logging into new tree
  190. //
  191. DEBUGOUT(("Logging in...\n"));
  192. ccode = pfNWDSLogin(context, 0, pszUser, pszPasswd, 0);
  193. if(ccode) {
  194. ERR(("\nNWDSLogin returned %X\n", ccode));
  195. BAIL();
  196. }
  197. else {
  198. fLoggedIn = TRUE;
  199. DEBUGOUT(("Logged in successfully.\n"));
  200. }
  201. doit:
  202. if(pfNWIsDSAuthenticated())
  203. DEBUGOUT(("The system has been authenticated already\n"));
  204. else
  205. DEBUGOUT(("The system is not authenticated.\n"));
  206. ccode = pfNWDSAllocBuf(DEFAULT_MESSAGE_LEN, &pInBuf);
  207. if(ccode) {
  208. ERR(("\nNWDSAllocBuf returned %X", ccode));
  209. BAIL();
  210. }
  211. ccode = pfNWDSAllocBuf(DEFAULT_MESSAGE_LEN, &pOutBuf);
  212. if(ccode) {
  213. ERR(("\nNWDSAllocBuf returned %X", ccode));
  214. BAIL();
  215. }
  216. ccode = pfNWDSInitBuf(context, DSV_READ_ATTR_DEF, pInBuf);
  217. if(ccode) {
  218. ERR(("\nNWDSInitBuf returned %X", ccode));
  219. BAIL();
  220. }
  221. ccode = pfNWDSPutAttrName(context, pInBuf, (PSTR)g_szAttributeNameA);
  222. if(ccode) {
  223. ERR(("\nNWDSPutAttrName returned %X", ccode));
  224. BAIL();
  225. }
  226. lIterationHandle = NO_MORE_ITERATIONS;
  227. ccode = pfNWDSReadAttrDef(context,
  228. DS_ATTR_DEFS, /* infoType, attribute definitions */
  229. FALSE, /* allAttrs = false, passing in one */
  230. pInBuf, /* through this buffer (strAttrNames) */
  231. &lIterationHandle,
  232. pOutBuf);
  233. if (ccode == ERR_NO_SUCH_ATTRIBUTE) {
  234. ccode = 0;
  235. BAIL();
  236. }
  237. else if (ccode) {
  238. ERR(("\nNWDSReadAttrDef returned %X", ccode));
  239. BAIL();
  240. }
  241. ccode = pfNWDSGetAttrCount(context, pOutBuf, &luTotalAttr);
  242. if(ccode) {
  243. ERR(("\nNWDSGetAttrCount returned %X", ccode));
  244. BAIL();
  245. }
  246. if (luTotalAttr == 1) {
  247. ccode = pfNWDSGetAttrDef(context, pOutBuf, strAttrName, &attrInfo);
  248. if(ccode) {
  249. ERR(("\nNWDSGetAttrCount returned %X", ccode));
  250. BAIL();
  251. }
  252. if (strcmp(strAttrName,(PSTR)g_szAttributeNameA) == 0) {
  253. fSchemaExtended = TRUE;
  254. }
  255. DEBUGOUT(("Successfully retrieved information off Client32.\n"));
  256. }
  257. error:
  258. if (fLogout & fLoggedIn) {
  259. DEBUGOUT(("We are logging out.\n",strName));
  260. pfNWDSLogout(context);
  261. }
  262. if (pInBuf)
  263. pfNWDSFreeBuf(pInBuf);
  264. if (pOutBuf)
  265. pfNWDSFreeBuf(pOutBuf);
  266. if (context)
  267. pfNWDSFreeContext(context);
  268. if (fFreeUnicodeTable)
  269. pfNWFreeUnicodeTables();
  270. if (pszServer)
  271. MemFree(pszServer);
  272. if (pszContext)
  273. MemFree(pszContext);
  274. if (pszUser)
  275. MemFree(pszUser);
  276. if (pszPasswd)
  277. MemFree(pszPasswd);
  278. *pfExtended = fSchemaExtended;
  279. if (WinError == 0 && (ccode != 0)) {
  280. WinError = ERROR_EXTENDED_ERROR;
  281. SelectivePrint(MSG_NETWARE_ERROR,ccode);
  282. }
  283. return WinError;
  284. }
  285. DWORD Client32ExtendSchema(
  286. PWSTR szServer,
  287. PWSTR szContext,
  288. PWSTR szUser,
  289. PWSTR szPasswd
  290. )
  291. {
  292. NWDSContextHandle context = NULL;
  293. pBuf_T pInBuf = NULL;
  294. pBuf_T pOutBuf = NULL;
  295. BOOL fFreeUnicodeTable = FALSE;
  296. BOOL fLoggedIn= FALSE;
  297. BOOL fLogout = TRUE;
  298. NWDSCCODE ccode;
  299. nstr8 strAttrName[MAX_SCHEMA_NAME_CHARS];
  300. nuint i;
  301. LCONV lConvInfo;
  302. DWORD dwSyntaxId;
  303. DWORD dwMinValue = 0;
  304. DWORD dwMaxValue = -1;
  305. Asn1ID_T *pasn1ID;
  306. Attr_Info_T AttrInfo;
  307. nstr8 treeName[MAX_DN_CHARS+1];
  308. nstr8 strName[MAX_DN_CHARS+1];
  309. DWORD WinError;
  310. PSTR pszServer = NULL;
  311. PSTR pszContext = NULL;
  312. PSTR pszUser = NULL;
  313. PSTR pszPasswd = NULL;
  314. //
  315. // We only check server and extended because they are the only must-have
  316. // parameters
  317. //
  318. if (!(szServer)) {
  319. ERR(("Invalid parameters.\n"));
  320. WinError = ERROR_INVALID_PARAMETER;
  321. BAIL();
  322. }
  323. WinError = LoadNetwareDLLs();
  324. if (WinError) {
  325. BAIL();
  326. }
  327. ccode = pfNWCallsInit(NULL,NULL);
  328. if (ccode) {
  329. ERR(("NWCallsInit returned %X\n", ccode));
  330. BAIL();
  331. }
  332. pfNWLlocaleconv(&lConvInfo);
  333. ccode = pfNWInitUnicodeTables(lConvInfo.country_id,
  334. lConvInfo.code_page);
  335. if (ccode) {
  336. ERR(("NWInitUnicodeTables returned %X\n", ccode));
  337. BAIL();
  338. }
  339. fFreeUnicodeTable = TRUE;
  340. context = pfNWDSCreateContext();
  341. if (context == (NWDSContextHandle)ERR_CONTEXT_CREATION) {
  342. ERR(("NWDSCreateContext failed\n"));
  343. BAIL();
  344. }
  345. pszServer = AllocateAnsiString(szServer);
  346. if (pszServer == NULL) {
  347. WinError = ERROR_NO_SYSTEM_RESOURCES;
  348. BAIL();
  349. }
  350. if (szContext == NULL) {
  351. goto extendnow;
  352. }
  353. pszContext = AllocateAnsiString(szContext);
  354. if (pszContext == NULL) {
  355. WinError = ERROR_NO_SYSTEM_RESOURCES;
  356. BAIL();
  357. }
  358. pszUser = AllocateAnsiString(szUser);
  359. if (pszUser == NULL) {
  360. WinError = ERROR_NO_SYSTEM_RESOURCES;
  361. BAIL();
  362. }
  363. pszPasswd = AllocateAnsiString(szPasswd);
  364. if (pszPasswd == NULL) {
  365. WinError = ERROR_NO_SYSTEM_RESOURCES;
  366. BAIL();
  367. }
  368. if(!pfNWIsDSAuthenticated()) {
  369. DEBUGOUT(("The system is not authenticated.\n"));
  370. }
  371. else {
  372. DEBUGOUT(("The system has been authenticated already\n"));
  373. //
  374. // Get Current tree's name
  375. //
  376. ccode = pfNWDSGetContext(context, DCK_TREE_NAME, &treeName);
  377. if(ccode) {
  378. ERR(("Get context returned %X\n", ccode));
  379. BAIL();
  380. }
  381. DEBUGOUT(("Current Tree is %s.\n",treeName));
  382. //
  383. // Get current context's name
  384. //
  385. ccode = pfNWDSGetContext(context, DCK_NAME_CONTEXT, &strName);
  386. if(ccode) {
  387. ERR(("\nGet context returned %X", ccode));
  388. BAIL();
  389. }
  390. DEBUGOUT(("Current Context is %s.\n",strName));
  391. //
  392. // If the current tree and context is the same as the desired tree
  393. // and context, we do not need to logout. Because that would blow out
  394. // the connection.
  395. //
  396. if ((_stricmp(treeName,pszServer) == 0) &&
  397. (_stricmp(strName,pszContext) == 0)) {
  398. DEBUGOUT(("Will not logout.\n",strName));
  399. fLogout = FALSE;
  400. }
  401. }
  402. //
  403. // Set context to another tree
  404. //
  405. ccode = pfNWDSSetContext(context,
  406. DCK_TREE_NAME,
  407. pszServer
  408. );
  409. if(ccode) {
  410. ERR(("\nSet context returned %X", ccode));
  411. BAIL();
  412. }
  413. //
  414. // Set context to another context
  415. //
  416. ccode = pfNWDSSetContext(
  417. context,
  418. DCK_NAME_CONTEXT,
  419. pszContext
  420. );
  421. if(ccode) {
  422. ERR(("\nSet context returned %X", ccode));
  423. BAIL();
  424. }
  425. //
  426. // Get Current tree's name
  427. //
  428. ccode = pfNWDSGetContext(context, DCK_TREE_NAME, &treeName);
  429. if(ccode) {
  430. ERR(("\nGet context returned %X", ccode));
  431. BAIL();
  432. }
  433. DEBUGOUT(("Current tree is %s.\n",treeName));
  434. ccode = pfNWDSGetContext(context, DCK_NAME_CONTEXT, &strName);
  435. if(ccode) {
  436. ERR(("\nGet context returned %X", ccode));
  437. BAIL();
  438. }
  439. DEBUGOUT(("Current conext is now %s.\n",strName));
  440. //
  441. // Logging into new tree
  442. //
  443. DEBUGOUT(("Logging in...\n"));
  444. ccode = pfNWDSLogin(context, 0, pszUser, pszPasswd, 0);
  445. if(ccode) {
  446. ERR(("\nNWDSLogin returned %X\n", ccode));
  447. BAIL();
  448. }
  449. else {
  450. fLoggedIn = TRUE;
  451. DEBUGOUT(("Logged in successfully.\n"));
  452. }
  453. extendnow:
  454. if(pfNWIsDSAuthenticated())
  455. DEBUGOUT(("The system has been authenticated already\n"));
  456. else
  457. DEBUGOUT(("The system is not authenticated.\n"));
  458. AttrInfo.attrFlags = DS_SINGLE_VALUED_ATTR;
  459. AttrInfo.attrSyntaxID = SYN_OCTET_STRING;
  460. AttrInfo.attrLower = dwMinValue;
  461. AttrInfo.attrUpper = dwMaxValue;
  462. pasn1ID = &(AttrInfo.asn1ID);
  463. memset(pasn1ID->data,0,32);
  464. pasn1ID->length = 32;
  465. memcpy(pasn1ID->data,g_pbASN,g_dwASN);
  466. ccode = pfNWDSDefineAttr(context,
  467. (PSTR)g_szAttributeNameA,
  468. &AttrInfo);
  469. if(ccode) {
  470. if (ccode == ERR_ATTRIBUTE_ALREADY_EXISTS) {
  471. ERR(("\nNWDSDefineAttr returned %X", ccode));
  472. ERR(("The schema has been extended already\n", ccode));
  473. WinError = 1;
  474. BAIL();
  475. }
  476. ERR(("\nNWDSDefineAttr returned %X", ccode));
  477. BAIL();
  478. }
  479. ccode = pfNWDSAllocBuf(DEFAULT_MESSAGE_LEN, &pInBuf);
  480. if(ccode) {
  481. ERR(("\nNWDSAllocBuf returned %X", ccode));
  482. BAIL();
  483. }
  484. ccode = pfNWDSInitBuf(context, DSV_MODIFY_CLASS_DEF, pInBuf);
  485. if(ccode) {
  486. ERR(("\nNWDSInitBuf returned %X", ccode));
  487. BAIL();
  488. }
  489. ccode = pfNWDSPutAttrName(context, pInBuf, (PSTR)g_szAttributeNameA);
  490. if(ccode) {
  491. ERR(("\nNWDSPutAttrName returned %X", ccode));
  492. BAIL();
  493. }
  494. ccode = pfNWDSModifyClassDef(context, (PSTR)g_szClassA, pInBuf);
  495. if(ccode) {
  496. if (ccode == ERR_DUPLICATE_OPTIONAL) {
  497. ERR(("\nNWDSPutAttrName returned %X\n",ccode));
  498. ERR(("The schema has been extended already\n", ccode));
  499. WinError = 1;
  500. BAIL();
  501. }
  502. ERR(("\nNWDSPutAttrName returned %X", ccode));
  503. BAIL();
  504. }
  505. error:
  506. if (fLogout & fLoggedIn) {
  507. DEBUGOUT(("We are logging out.\n",strName));
  508. pfNWDSLogout(context);
  509. }
  510. if (pInBuf)
  511. pfNWDSFreeBuf(pInBuf);
  512. if (context)
  513. pfNWDSFreeContext(context);
  514. if (fFreeUnicodeTable)
  515. pfNWFreeUnicodeTables();
  516. if (pszServer)
  517. MemFree(pszServer);
  518. if (pszContext)
  519. MemFree(pszContext);
  520. if (pszUser)
  521. MemFree(pszUser);
  522. if (pszPasswd)
  523. MemFree(pszPasswd);
  524. if (WinError == 0 && (ccode != 0)) {
  525. WinError = ERROR_EXTENDED_ERROR;
  526. SelectivePrint(MSG_NETWARE_ERROR,ccode);
  527. }
  528. return WinError;
  529. }
  530. DWORD LoadNetwareDLLs()
  531. {
  532. DWORD WinError = 0;
  533. calwin32LibraryHandle = LoadLibraryA("calwin32.DLL");
  534. if (calwin32LibraryHandle == NULL) {
  535. WinError = GetLastError();
  536. ERR(("loadlib failed with %d\n,WinError"));
  537. BAIL();
  538. }
  539. locwin32LibraryHandle = LoadLibraryA("locwin32.DLL");
  540. if (locwin32LibraryHandle == NULL) {
  541. WinError = GetLastError();
  542. ERR(("loadlib failed with %d\n,WinError"));
  543. BAIL();
  544. }
  545. netwin32LibraryHandle = LoadLibraryA("netwin32.DLL");
  546. if (netwin32LibraryHandle == NULL) {
  547. WinError = GetLastError();
  548. ERR(("loadlib failed with %d\n,WinError"));
  549. BAIL();
  550. }
  551. pfNWCallsInit = (PF_NWCallsInit) GetProcAddress(
  552. calwin32LibraryHandle,
  553. "NWCallsInit");
  554. if (pfNWCallsInit == NULL) {
  555. WinError = GetLastError();
  556. ERR(("getprocaddress failed with %d\n,WinError"));
  557. BAIL();
  558. }
  559. pfNWFreeUnicodeTables = (PF_NWFreeUnicodeTables) GetProcAddress(
  560. locwin32LibraryHandle,
  561. "NWFreeUnicodeTables");
  562. if (pfNWFreeUnicodeTables == NULL) {
  563. WinError = GetLastError();
  564. ERR(("getprocaddress failed with %d\n,WinError"));
  565. BAIL();
  566. }
  567. pfNWInitUnicodeTables = (PF_NWInitUnicodeTables) GetProcAddress(
  568. locwin32LibraryHandle,
  569. "NWInitUnicodeTables");
  570. if (pfNWInitUnicodeTables == NULL) {
  571. WinError = GetLastError();
  572. ERR(("getprocaddress failed with %d\n,WinError"));
  573. BAIL();
  574. }
  575. pfNWLlocaleconv = (PF_NWLlocaleconv) GetProcAddress(
  576. locwin32LibraryHandle,
  577. "NWLlocaleconv");
  578. if (pfNWLlocaleconv == NULL) {
  579. WinError = GetLastError();
  580. ERR(("getprocaddress failed with %d\n,WinError"));
  581. BAIL();
  582. }
  583. pfNWDSFreeContext = (PF_NWDSFreeContext) GetProcAddress(
  584. netwin32LibraryHandle,
  585. "NWDSFreeContext");
  586. if (pfNWDSFreeContext == NULL) {
  587. WinError = GetLastError();
  588. ERR(("getprocaddress failed with %d\n,WinError"));
  589. BAIL();
  590. }
  591. pfNWDSFreeBuf = (PF_NWDSFreeBuf) GetProcAddress(
  592. netwin32LibraryHandle,
  593. "NWDSFreeBuf");
  594. if (pfNWDSFreeBuf == NULL) {
  595. WinError = GetLastError();
  596. ERR(("getprocaddress failed with %d\n,WinError"));
  597. BAIL();
  598. }
  599. pfNWDSLogout = (PF_NWDSLogout) GetProcAddress(
  600. netwin32LibraryHandle,
  601. "NWDSLogout");
  602. if (pfNWDSLogout == NULL) {
  603. WinError = GetLastError();
  604. ERR(("getprocaddress failed with %d\n,WinError"));
  605. BAIL();
  606. }
  607. pfNWDSGetAttrDef = (PF_NWDSGetAttrDef) GetProcAddress(
  608. netwin32LibraryHandle,
  609. "NWDSGetAttrDef");
  610. if (pfNWDSGetAttrDef == NULL) {
  611. WinError = GetLastError();
  612. ERR(("getprocaddress failed with %d\n,WinError"));
  613. BAIL();
  614. }
  615. pfNWDSGetAttrCount = (PF_NWDSGetAttrCount) GetProcAddress(
  616. netwin32LibraryHandle,
  617. "NWDSGetAttrCount");
  618. if (pfNWDSGetAttrCount == NULL) {
  619. WinError = GetLastError();
  620. ERR(("getprocaddress failed with %d\n,WinError"));
  621. BAIL();
  622. }
  623. pfNWDSReadAttrDef = (PF_NWDSReadAttrDef) GetProcAddress(
  624. netwin32LibraryHandle,
  625. "NWDSReadAttrDef");
  626. if (pfNWDSReadAttrDef == NULL) {
  627. WinError = GetLastError();
  628. ERR(("getprocaddress failed with %d\n,WinError"));
  629. BAIL();
  630. }
  631. pfNWDSPutAttrName = (PF_NWDSPutAttrName) GetProcAddress(
  632. netwin32LibraryHandle,
  633. "NWDSPutAttrName");
  634. if (pfNWDSPutAttrName == NULL) {
  635. WinError = GetLastError();
  636. ERR(("getprocaddress failed with %d\n,WinError"));
  637. BAIL();
  638. }
  639. pfNWDSInitBuf = (PF_NWDSInitBuf) GetProcAddress(
  640. netwin32LibraryHandle,
  641. "NWDSInitBuf");
  642. if (pfNWDSInitBuf == NULL) {
  643. WinError = GetLastError();
  644. ERR(("getprocaddress failed with %d\n,WinError"));
  645. BAIL();
  646. }
  647. pfNWDSAllocBuf = (PF_NWDSAllocBuf) GetProcAddress(
  648. netwin32LibraryHandle,
  649. "NWDSAllocBuf");
  650. if (pfNWDSAllocBuf == NULL) {
  651. WinError = GetLastError();
  652. ERR(("getprocaddress failed with %d\n,WinError"));
  653. BAIL();
  654. }
  655. pfNWDSLogin = (PF_NWDSLogin) GetProcAddress(
  656. netwin32LibraryHandle,
  657. "NWDSLogin");
  658. if (pfNWDSLogin == NULL) {
  659. WinError = GetLastError();
  660. ERR(("getprocaddress failed with %d\n,WinError"));
  661. BAIL();
  662. }
  663. pfNWDSSetContext = (PF_NWDSSetContext) GetProcAddress(
  664. netwin32LibraryHandle,
  665. "NWDSSetContext");
  666. if (pfNWDSSetContext == NULL) {
  667. WinError = GetLastError();
  668. ERR(("getprocaddress failed with %d\n,WinError"));
  669. BAIL();
  670. }
  671. pfNWDSGetContext = (PF_NWDSGetContext) GetProcAddress(
  672. netwin32LibraryHandle,
  673. "NWDSGetContext");
  674. if (pfNWDSGetContext == NULL) {
  675. WinError = GetLastError();
  676. ERR(("getprocaddress failed with %d\n,WinError"));
  677. BAIL();
  678. }
  679. pfNWIsDSAuthenticated = (PF_NWIsDSAuthenticated) GetProcAddress(
  680. netwin32LibraryHandle,
  681. "NWIsDSAuthenticated");
  682. if (pfNWIsDSAuthenticated == NULL) {
  683. WinError = GetLastError();
  684. ERR(("getprocaddress failed with %d\n,WinError"));
  685. BAIL();
  686. }
  687. pfNWDSCreateContext = (PF_NWDSCreateContext) GetProcAddress(
  688. netwin32LibraryHandle,
  689. "NWDSCreateContext");
  690. if (pfNWDSCreateContext == NULL) {
  691. WinError = GetLastError();
  692. ERR(("getprocaddress failed with %d\n,WinError"));
  693. BAIL();
  694. }
  695. pfNWDSModifyClassDef = (PF_NWDSModifyClassDef) GetProcAddress(
  696. netwin32LibraryHandle,
  697. "NWDSModifyClassDef");
  698. if (pfNWDSModifyClassDef == NULL) {
  699. WinError = GetLastError();
  700. ERR(("getprocaddress failed with %d\n,WinError"));
  701. BAIL();
  702. }
  703. pfNWDSDefineAttr = (PF_NWDSDefineAttr) GetProcAddress(
  704. netwin32LibraryHandle,
  705. "NWDSDefineAttr");
  706. if (pfNWDSDefineAttr== NULL) {
  707. WinError = GetLastError();
  708. ERR(("getprocaddress failed with %d\n,WinError"));
  709. BAIL();
  710. }
  711. error:
  712. return WinError;
  713. }