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.

702 lines
23 KiB

  1. //****************************************************************************
  2. //
  3. // Module: ULS.DLL
  4. // File: ldapstub.cpp
  5. // Content: ULS/LDAP stubbed functions
  6. //
  7. // Copyright (c) Microsoft Corporation 1996-1997
  8. //
  9. //****************************************************************************
  10. #include "ulsp.h"
  11. HWND g_hwndCB = NULL;
  12. ULONG uMsgID;
  13. //
  14. // Initialization
  15. //
  16. HRESULT UlsLdap_Initialize (
  17. HWND hwndCallback)
  18. {
  19. uMsgID = 1;
  20. g_hwndCB = hwndCallback;
  21. return S_OK;
  22. }
  23. HRESULT UlsLdap_Deinitialize (void)
  24. {
  25. uMsgID = 0;
  26. g_hwndCB = NULL;
  27. return S_OK;
  28. }
  29. HRESULT UlsLdap_Cancel (
  30. ULONG uReqID)
  31. {
  32. return S_OK;
  33. }
  34. //
  35. // Local machine information
  36. //
  37. HRESULT UlsLdap_RegisterUser (
  38. LPTSTR pszServer,
  39. PLDAP_USERINFO pUserInfo,
  40. PHANDLE phUser,
  41. PLDAP_ASYNCINFO pAsyncInfo )
  42. {
  43. *phUser = (HANDLE)(0x11111111);
  44. pAsyncInfo->uMsgID = uMsgID;
  45. PostMessage(g_hwndCB, WM_ULS_REGISTER_USER, uMsgID, NOERROR);
  46. uMsgID++;
  47. return NOERROR;
  48. }
  49. HRESULT UlsLdap_RegisterApp (
  50. HANDLE hUser,
  51. PLDAP_APPINFO pAppInfo,
  52. PHANDLE phApp,
  53. PLDAP_ASYNCINFO pAsyncInfo )
  54. {
  55. if (hUser != (HANDLE)(0x11111111))
  56. {
  57. ASSERT(0);
  58. return ULS_E_FAIL;
  59. };
  60. *phApp = (HANDLE)(0x22222222);
  61. pAsyncInfo->uMsgID = uMsgID;
  62. PostMessage(g_hwndCB, WM_ULS_REGISTER_APP, uMsgID, NOERROR);
  63. uMsgID++;
  64. return NOERROR;
  65. }
  66. HRESULT UlsLdap_RegisterProtocol (
  67. HANDLE hApp,
  68. PLDAP_PROTINFO pProtInfo,
  69. PHANDLE phProtocol,
  70. PLDAP_ASYNCINFO pAsyncInfo )
  71. {
  72. if (hApp != (HANDLE)(0x22222222))
  73. {
  74. ASSERT(0);
  75. return ULS_E_FAIL;
  76. };
  77. *phProtocol = (HANDLE)(0x44444444);
  78. pAsyncInfo->uMsgID = uMsgID;
  79. PostMessage(g_hwndCB, WM_ULS_REGISTER_PROTOCOL, uMsgID, NOERROR);
  80. uMsgID++;
  81. return NOERROR;
  82. }
  83. HRESULT UlsLdap_UnRegisterUser (
  84. HANDLE hUser,
  85. PLDAP_ASYNCINFO pAsyncInfo )
  86. {
  87. if (hUser != (HANDLE)(0x11111111))
  88. {
  89. ASSERT(0);
  90. return ULS_E_FAIL;
  91. };
  92. pAsyncInfo->uMsgID = uMsgID;
  93. PostMessage(g_hwndCB, WM_ULS_UNREGISTER_USER, uMsgID, NOERROR);
  94. uMsgID++;
  95. return NOERROR;
  96. }
  97. HRESULT UlsLdap_UnRegisterApp (
  98. HANDLE hApp,
  99. PLDAP_ASYNCINFO pAsyncInfo )
  100. {
  101. if (hApp != (HANDLE)(0x22222222))
  102. {
  103. ASSERT(0);
  104. return ULS_E_FAIL;
  105. };
  106. pAsyncInfo->uMsgID = uMsgID;
  107. PostMessage(g_hwndCB, WM_ULS_UNREGISTER_APP, uMsgID, NOERROR);
  108. uMsgID++;
  109. return NOERROR;
  110. }
  111. HRESULT UlsLdap_UnRegisterProtocol (
  112. HANDLE hProt,
  113. PLDAP_ASYNCINFO pAsyncInfo )
  114. {
  115. if (hProt != (HANDLE)(0x44444444))
  116. {
  117. ASSERT(0);
  118. return ULS_E_FAIL;
  119. };
  120. pAsyncInfo->uMsgID = uMsgID;
  121. PostMessage(g_hwndCB, WM_ULS_UNREGISTER_PROTOCOL, uMsgID, NOERROR);
  122. uMsgID++;
  123. return NOERROR;
  124. }
  125. HRESULT UlsLdap_SetUserInfo (
  126. HANDLE hUser,
  127. PLDAP_USERINFO pInfo,
  128. PLDAP_ASYNCINFO pAsyncInfo )
  129. {
  130. pAsyncInfo->uMsgID = uMsgID;
  131. PostMessage(g_hwndCB, WM_ULS_SET_USER_INFO, uMsgID, NOERROR);
  132. uMsgID++;
  133. return NOERROR;
  134. }
  135. HRESULT UlsLdap_SetAppAttrs (
  136. HANDLE hApp,
  137. ULONG cAttrs,
  138. LPTSTR pszAttrs,
  139. PLDAP_ASYNCINFO pAsyncInfo )
  140. {
  141. pAsyncInfo->uMsgID = uMsgID;
  142. PostMessage(g_hwndCB, WM_ULS_SET_APP_ATTRS, uMsgID, NOERROR);
  143. uMsgID++;
  144. return NOERROR;
  145. }
  146. HRESULT UlsLdap_SetProtocolAttrs (
  147. HANDLE hProt,
  148. ULONG cAttrs,
  149. LPTSTR pszAttrs,
  150. PLDAP_ASYNCINFO pAsyncInfo )
  151. {
  152. pAsyncInfo->uMsgID = uMsgID;
  153. PostMessage(g_hwndCB, WM_ULS_SET_PROTOCOL_ATTRS, uMsgID, NOERROR);
  154. uMsgID++;
  155. return NOERROR;
  156. }
  157. HRESULT UlsLdap_RemoveAppAttrs (
  158. HANDLE hApp,
  159. ULONG cAttrs,
  160. LPTSTR pszAttrNames,
  161. PLDAP_ASYNCINFO pAsyncInfo )
  162. {
  163. pAsyncInfo->uMsgID = uMsgID;
  164. PostMessage(g_hwndCB, WM_ULS_REMOVE_APP_ATTRS, uMsgID, NOERROR);
  165. uMsgID++;
  166. return NOERROR;
  167. }
  168. HRESULT UlsLdap_RemoveProtocolAttrs (
  169. HANDLE hApp,
  170. ULONG cAttrs,
  171. LPTSTR pszAttrNames,
  172. PLDAP_ASYNCINFO pAsyncInfo )
  173. {
  174. pAsyncInfo->uMsgID = uMsgID;
  175. PostMessage(g_hwndCB, WM_ULS_REMOVE_PROTOCOL_ATTRS, uMsgID, NOERROR);
  176. uMsgID++;
  177. return NOERROR;
  178. }
  179. //
  180. // User Location Services request
  181. //
  182. static TCHAR c_szEnumNames_1[] = {TEXT("User_1") TEXT("\0")
  183. TEXT("User_2") TEXT("\0")
  184. TEXT("User_3") TEXT("\0")
  185. TEXT("User_4") TEXT("\0\0")};
  186. static TCHAR c_szEnumNames_2[] = {TEXT("User_5") TEXT("\0")
  187. TEXT("User_6") TEXT("\0")
  188. TEXT("User_7") TEXT("\0")
  189. TEXT("User_8") TEXT("\0\0")};
  190. HRESULT UlsLdap_EnumUsers (
  191. LPTSTR pszServer,
  192. PLDAP_ASYNCINFO pAsyncInfo )
  193. {
  194. PLDAP_ENUM ple;
  195. // First batch
  196. //
  197. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+sizeof(c_szEnumNames_1));
  198. ple->uSize = sizeof(*ple);
  199. ple->hResult = NOERROR;
  200. ple->cItems = 4;
  201. ple->uOffsetItems = ple->uSize;
  202. CopyMemory(((PBYTE)ple)+ple->uOffsetItems, c_szEnumNames_1,
  203. sizeof(c_szEnumNames_1));
  204. PostMessage(g_hwndCB, WM_ULS_ENUM_USERS, uMsgID, (LPARAM)ple);
  205. // Second batch
  206. //
  207. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+sizeof(c_szEnumNames_2));
  208. ple->uSize = sizeof(*ple);
  209. ple->hResult = NOERROR;
  210. ple->cItems = 4;
  211. ple->uOffsetItems = ple->uSize;
  212. CopyMemory(((PBYTE)ple)+ple->uOffsetItems, c_szEnumNames_2,
  213. sizeof(c_szEnumNames_2));
  214. PostMessage(g_hwndCB, WM_ULS_ENUM_USERS, uMsgID, (LPARAM)ple);
  215. // Terminate
  216. //
  217. PostMessage(g_hwndCB, WM_ULS_ENUM_USERS, uMsgID, (LPARAM)NULL);
  218. pAsyncInfo->uMsgID = uMsgID;
  219. uMsgID++;
  220. return NOERROR;
  221. }
  222. HRESULT UlsLdap_ResolveUser (
  223. LPTSTR pszServer,
  224. LPTSTR pszUserName,
  225. PLDAP_ASYNCINFO pAsyncInfo )
  226. {
  227. PLDAP_USERINFO_RES plur;
  228. PLDAP_USERINFO plu;
  229. ULONG cLen;
  230. plur = (PLDAP_USERINFO_RES)LocalAlloc(LMEM_FIXED, sizeof(*plur)+
  231. (sizeof(TCHAR)*MAX_PATH));
  232. plur->uSize = sizeof(*plur);
  233. plur->hResult = NOERROR;
  234. plu = &(plur->lui);
  235. plu->uSize = sizeof(LDAP_USERINFO);
  236. plu->uOffsetName = plu->uSize;
  237. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  238. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  239. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  240. pszUserName) + 1;
  241. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  242. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  243. pszUserName) + 1;
  244. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  245. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  246. pszUserName) + 1;
  247. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  248. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  249. pszUserName) + 1;
  250. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  251. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  252. pszUserName) + 1;
  253. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  254. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  255. pszUserName) + 1;
  256. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  257. lstrcpy((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.1.100.2"));
  258. plu->dwFlags = 1;
  259. pAsyncInfo->uMsgID = uMsgID;
  260. PostMessage(g_hwndCB, WM_ULS_RESOLVE_USER, uMsgID, (LPARAM)plur);
  261. uMsgID++;
  262. return S_OK;
  263. }
  264. HRESULT UlsLdap_EnumUserInfos (
  265. LPTSTR pszServer,
  266. PLDAP_ASYNCINFO pAsyncInfo )
  267. {
  268. PLDAP_ENUM ple;
  269. PLDAP_USERINFO plu;
  270. LPTSTR pszUserName;
  271. ULONG uOffsetLast;
  272. ULONG cLen;
  273. // First batch
  274. //
  275. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+
  276. 3*sizeof(LDAP_USERINFO)+
  277. 3*sizeof(TCHAR)*MAX_PATH);
  278. ple->uSize = sizeof(*ple);
  279. ple->hResult = NOERROR;
  280. ple->cItems = 3;
  281. ple->uOffsetItems = ple->uSize;
  282. // First batch--First guy
  283. //
  284. pszUserName = c_szEnumNames_1;
  285. plu = (PLDAP_USERINFO)(((PBYTE)ple)+ple->uOffsetItems);
  286. plu->uSize = sizeof(LDAP_USERINFO);
  287. plu->uOffsetName = sizeof(*plu)*3;
  288. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  289. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  290. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  291. pszUserName) + 1;
  292. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  293. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  294. pszUserName) + 1;
  295. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  296. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  297. pszUserName) + 1;
  298. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  299. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  300. pszUserName) + 1;
  301. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  302. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  303. pszUserName) + 1;
  304. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  305. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  306. pszUserName) + 1;
  307. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  308. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.1.100.2"))+1;
  309. plu->dwFlags = 1;
  310. uOffsetLast = plu->uOffsetIPAddress+cLen;
  311. // First batch--Second guy
  312. //
  313. pszUserName += lstrlen(pszUserName)+1;
  314. plu = (PLDAP_USERINFO)plu+1;
  315. plu->uSize = sizeof(LDAP_USERINFO);
  316. plu->uOffsetName = uOffsetLast-sizeof(*plu);
  317. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  318. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  319. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  320. pszUserName) + 1;
  321. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  322. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  323. pszUserName) + 1;
  324. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  325. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  326. pszUserName) + 1;
  327. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  328. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  329. pszUserName) + 1;
  330. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  331. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  332. pszUserName) + 1;
  333. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  334. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  335. pszUserName) + 1;
  336. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  337. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.2.100.2"))+1;
  338. plu->dwFlags = 1;
  339. uOffsetLast = plu->uOffsetIPAddress+cLen;
  340. // First batch--Third guy
  341. //
  342. pszUserName += lstrlen(pszUserName)+1;
  343. plu = (PLDAP_USERINFO)plu+1;
  344. plu->uSize = sizeof(LDAP_USERINFO);
  345. plu->uOffsetName = uOffsetLast-sizeof(*plu);
  346. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  347. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  348. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  349. pszUserName) + 1;
  350. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  351. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  352. pszUserName) + 1;
  353. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  354. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  355. pszUserName) + 1;
  356. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  357. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  358. pszUserName) + 1;
  359. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  360. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  361. pszUserName) + 1;
  362. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  363. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  364. pszUserName) + 1;
  365. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  366. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.3.100.2"))+1;
  367. plu->dwFlags = 1;
  368. uOffsetLast = plu->uOffsetIPAddress+cLen;
  369. PostMessage(g_hwndCB, WM_ULS_ENUM_USERINFOS, uMsgID, (LPARAM)ple);
  370. // Second batch
  371. //
  372. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+
  373. 3*sizeof(LDAP_USERINFO)+
  374. 3*sizeof(TCHAR)*MAX_PATH);
  375. ple->uSize = sizeof(*ple);
  376. ple->hResult = NOERROR;
  377. ple->cItems = 3;
  378. ple->uOffsetItems = ple->uSize;
  379. // Second batch--First guy
  380. //
  381. pszUserName = c_szEnumNames_2;
  382. plu = (PLDAP_USERINFO)(((PBYTE)ple)+ple->uOffsetItems);
  383. plu->uSize = sizeof(LDAP_USERINFO);
  384. plu->uOffsetName = sizeof(*plu)*3;
  385. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  386. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  387. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  388. pszUserName) + 1;
  389. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  390. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  391. pszUserName) + 1;
  392. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  393. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  394. pszUserName) + 1;
  395. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  396. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  397. pszUserName) + 1;
  398. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  399. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  400. pszUserName) + 1;
  401. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  402. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  403. pszUserName) + 1;
  404. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  405. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.1.100.2"))+1;
  406. plu->dwFlags = 1;
  407. uOffsetLast = plu->uOffsetIPAddress+cLen;
  408. // Second batch--Second guy
  409. //
  410. pszUserName += lstrlen(pszUserName)+1;
  411. plu = (PLDAP_USERINFO)plu+1;
  412. plu->uSize = sizeof(LDAP_USERINFO);
  413. plu->uOffsetName = uOffsetLast-sizeof(*plu);
  414. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  415. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  416. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  417. pszUserName) + 1;
  418. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  419. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  420. pszUserName) + 1;
  421. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  422. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  423. pszUserName) + 1;
  424. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  425. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  426. pszUserName) + 1;
  427. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  428. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  429. pszUserName) + 1;
  430. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  431. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  432. pszUserName) + 1;
  433. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  434. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.2.100.2"))+1;
  435. plu->dwFlags = 1;
  436. uOffsetLast = plu->uOffsetIPAddress+cLen;
  437. // Second batch--Third guy
  438. //
  439. pszUserName += lstrlen(pszUserName)+1;
  440. plu = (PLDAP_USERINFO)plu+1;
  441. plu->uSize = sizeof(LDAP_USERINFO);
  442. plu->uOffsetName = uOffsetLast-sizeof(*plu);
  443. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetName), TEXT("%s"), pszUserName) + 1;
  444. plu->uOffsetFirstName = plu->uOffsetName+cLen;
  445. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetFirstName), TEXT("%s_First"),
  446. pszUserName) + 1;
  447. plu->uOffsetLastName = plu->uOffsetFirstName+cLen;
  448. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetLastName), TEXT("%s_Last"),
  449. pszUserName) + 1;
  450. plu->uOffsetEMailName = plu->uOffsetLastName+cLen;
  451. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetEMailName), TEXT("%s"),
  452. pszUserName) + 1;
  453. plu->uOffsetCityName = plu->uOffsetEMailName+cLen;
  454. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCityName), TEXT("%sville"),
  455. pszUserName) + 1;
  456. plu->uOffsetCountryName = plu->uOffsetCityName+cLen;
  457. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetCountryName), TEXT("%sland"),
  458. pszUserName) + 1;
  459. plu->uOffsetComment = plu->uOffsetCountryName+cLen;
  460. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetComment), TEXT("%s's comment"),
  461. pszUserName) + 1;
  462. plu->uOffsetIPAddress = plu->uOffsetComment+cLen;
  463. cLen = wsprintf((LPTSTR)(((PBYTE)plu)+plu->uOffsetIPAddress), TEXT("125.3.100.2"))+1;
  464. plu->dwFlags = 1;
  465. uOffsetLast = plu->uOffsetIPAddress+cLen;
  466. PostMessage(g_hwndCB, WM_ULS_ENUM_USERINFOS, uMsgID, (LPARAM)ple);
  467. // Termination
  468. //
  469. PostMessage(g_hwndCB, WM_ULS_ENUM_USERINFOS, uMsgID, (LPARAM)NULL);
  470. pAsyncInfo->uMsgID = uMsgID;
  471. uMsgID++;
  472. return NOERROR;
  473. }
  474. static TCHAR c_szEnumApps[] = {TEXT("App_1") TEXT("\0")
  475. TEXT("App_2") TEXT("\0")
  476. TEXT("App_3") TEXT("\0")
  477. TEXT("App_4") TEXT("\0\0")};
  478. HRESULT UlsLdap_EnumApps (
  479. LPTSTR pszServer,
  480. LPTSTR pszUserName,
  481. PLDAP_ASYNCINFO pAsyncInfo )
  482. {
  483. PLDAP_ENUM ple;
  484. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+sizeof(c_szEnumApps));
  485. ple->uSize = sizeof(*ple);
  486. ple->hResult = NOERROR;
  487. ple->cItems = 4;
  488. ple->uOffsetItems = ple->uSize;
  489. CopyMemory(((PBYTE)ple)+ple->uOffsetItems, c_szEnumApps,
  490. sizeof(c_szEnumApps));
  491. pAsyncInfo->uMsgID = uMsgID;
  492. PostMessage(g_hwndCB, WM_ULS_ENUM_APPS, uMsgID, (LPARAM)ple);
  493. uMsgID++;
  494. return NOERROR;
  495. }
  496. static TCHAR c_szAttributes[] = {TEXT("Attr_1") TEXT("\0") TEXT("Value_1") TEXT("\0")
  497. TEXT("Attr_2") TEXT("\0") TEXT("Value_2") TEXT("\0")
  498. TEXT("Attr_3") TEXT("\0") TEXT("Value_3") TEXT("\0")};
  499. HRESULT UlsLdap_ResolveApp (
  500. LPTSTR pszServer,
  501. LPTSTR pszUserName,
  502. LPTSTR pszAppName,
  503. PLDAP_ASYNCINFO pAsyncInfo )
  504. {
  505. PLDAP_APPINFO_RES plar;
  506. PLDAP_APPINFO pla;
  507. ULONG cLen;
  508. plar = (PLDAP_APPINFO_RES)LocalAlloc(LMEM_FIXED, sizeof(*plar)+
  509. (sizeof(TCHAR)*MAX_PATH));
  510. plar->uSize = sizeof(*plar);
  511. plar->hResult = NOERROR;
  512. pla = &(plar->lai);
  513. pla->uSize = sizeof(LDAP_APPINFO);
  514. pla->guid = IID_IEnumULSNames;
  515. pla->uOffsetName = pla->uSize;
  516. cLen = wsprintf((LPTSTR)(((PBYTE)pla)+pla->uOffsetName), TEXT("%s"), pszAppName) + 1;
  517. pla->uOffsetMimeType = pla->uOffsetName+cLen;
  518. cLen = wsprintf((LPTSTR)(((PBYTE)pla)+pla->uOffsetMimeType), TEXT("application\\%s"),
  519. pszAppName) + 1;
  520. pla->cAttributes = 3;
  521. pla->uOffsetAttributes = pla->uOffsetMimeType+cLen;
  522. CopyMemory((LPBYTE)(((PBYTE)pla)+pla->uOffsetAttributes),
  523. c_szAttributes, sizeof(c_szAttributes));
  524. pAsyncInfo->uMsgID = uMsgID;
  525. PostMessage(g_hwndCB, WM_ULS_RESOLVE_APP, uMsgID, (LPARAM)plar);
  526. uMsgID++;
  527. return S_OK;
  528. }
  529. static TCHAR c_szEnumProts[] = {TEXT("Prot_1") TEXT("\0")
  530. TEXT("Prot_2") TEXT("\0")
  531. TEXT("Prot_3") TEXT("\0")
  532. TEXT("Prot_4") TEXT("\0\0")};
  533. HRESULT UlsLdap_EnumProtocols (
  534. LPTSTR pszServer,
  535. LPTSTR pszUserName,
  536. LPTSTR pszAppName,
  537. PLDAP_ASYNCINFO pAsyncInfo )
  538. {
  539. PLDAP_ENUM ple;
  540. ple = (PLDAP_ENUM)LocalAlloc(LMEM_FIXED, sizeof(*ple)+sizeof(c_szEnumProts));
  541. ple->uSize = sizeof(*ple);
  542. ple->hResult = NOERROR;
  543. ple->cItems = 4;
  544. ple->uOffsetItems = ple->uSize;
  545. CopyMemory(((PBYTE)ple)+ple->uOffsetItems, c_szEnumProts,
  546. sizeof(c_szEnumProts));
  547. pAsyncInfo->uMsgID = uMsgID;
  548. PostMessage(g_hwndCB, WM_ULS_ENUM_PROTOCOLS, uMsgID, (LPARAM)ple);
  549. uMsgID++;
  550. return NOERROR;
  551. }
  552. HRESULT UlsLdap_ResolveProtocol (
  553. LPTSTR pszServer,
  554. LPTSTR pszUserName,
  555. LPTSTR pszAppName,
  556. LPTSTR pszProtName,
  557. PLDAP_ASYNCINFO pAsyncInfo )
  558. {
  559. PLDAP_PROTINFO_RES plpr;
  560. PLDAP_PROTINFO plp;
  561. ULONG cLen;
  562. plpr = (PLDAP_PROTINFO_RES)LocalAlloc(LMEM_FIXED, sizeof(*plpr)+
  563. (sizeof(TCHAR)*MAX_PATH));
  564. plpr->uSize = sizeof(*plpr);
  565. plpr->hResult = NOERROR;
  566. plp = &(plpr->lpi);
  567. plp->uSize = sizeof(LDAP_PROTINFO);
  568. plp->uPortNumber = 80;
  569. plp->uOffsetName = plp->uSize;
  570. cLen = wsprintf((LPTSTR)(((PBYTE)plp)+plp->uOffsetName), TEXT("%s"), pszProtName) + 1;
  571. plp->uOffsetMimeType = plp->uOffsetName+cLen;
  572. cLen = wsprintf((LPTSTR)(((PBYTE)plp)+plp->uOffsetMimeType), TEXT("protocol\\%s"),
  573. pszProtName) + 1;
  574. plp->cAttributes = 3;
  575. plp->uOffsetAttributes = plp->uOffsetMimeType+cLen;
  576. CopyMemory((LPBYTE)(((PBYTE)plp)+plp->uOffsetAttributes),
  577. c_szAttributes, sizeof(c_szAttributes));
  578. pAsyncInfo->uMsgID = uMsgID;
  579. PostMessage(g_hwndCB, WM_ULS_RESOLVE_PROTOCOL, uMsgID, (LPARAM)plpr);
  580. uMsgID++;
  581. return S_OK;
  582. }