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.

364 lines
9.8 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. NdsLib32.h
  5. Abstract:
  6. This module exposes the minimal win32 API to Netware directory
  7. services support in the Netware redirector.
  8. Author:
  9. Cory West [CoryWest] 23-Feb-1995
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <ntdef.h>
  16. #include <stdio.h>
  17. #include <ntddnwfs.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. NTSTATUS
  22. NwNdsOpenTreeHandle(
  23. IN PUNICODE_STRING puNdsTree,
  24. OUT PHANDLE phNwRdrHandle
  25. );
  26. // NwNdsOpenTreeHandle( PUNICODE_STRING, PHANDLE )
  27. //
  28. // Given an NDS tree name, this opens a handle the the redirector
  29. // for accessing that tree. The handle should closed using the
  30. // standard NT CloseHandle() call. This function is only a
  31. // simple wrapper around NT OpenFile().
  32. //
  33. // Administrativa.
  34. //
  35. #define HANDLE_TYPE_NCP_SERVER 1
  36. #define HANDLE_TYPE_NDS_TREE 2
  37. NTSTATUS
  38. NwNdsOpenGenericHandle(
  39. IN PUNICODE_STRING puNdsTree,
  40. OUT LPDWORD lpdwHandleType,
  41. OUT PHANDLE phNwRdrHandle
  42. );
  43. // NwNdsOpenGenericHandle( PUNICODE_STRING, LPDWORD, PHANDLE )
  44. //
  45. // Given a name, this opens a handle the the redirector for accessing that
  46. // named tree or server. lpdwHandleType is set to either HANDLE_TYPE_NCP_SERVER
  47. // or HANDLE_TYPE_NDS_TREE accordingly. The handle should be closed using
  48. // the standard NT CloseHandle() call. This function is only a simple
  49. // wrapper around NT OpenFile().
  50. NTSTATUS
  51. NwOpenHandleWithSupplementalCredentials(
  52. IN PUNICODE_STRING puResourceName,
  53. IN PUNICODE_STRING puUserName,
  54. IN PUNICODE_STRING puPassword,
  55. OUT LPDWORD lpdwHandleType,
  56. OUT PHANDLE phNwHandle
  57. );
  58. // NwOpenHandleWithSupplementalCredentials
  59. //
  60. // Given a resource name (either a server name or a tree name),
  61. // open a handle to that resource with the provided username and
  62. // password. As with the open generic handle routine, lpdsHandleType
  63. // will be set to either HANDLE_TYPE_NCP_SERVER or
  64. // HANDLE_TYPE_NDS_TREE based on the result of the open.
  65. //
  66. // Administrativa.
  67. //
  68. NTSTATUS
  69. NwNdsSetTreeContext (
  70. IN HANDLE hNdsRdr,
  71. IN PUNICODE_STRING puTree,
  72. IN PUNICODE_STRING puContext
  73. );
  74. // NwNdsSetTreeContext(HANDLE, PUNICODE_STRING, PUNICODE_STRING)
  75. //
  76. // Set the current context for the specified tree.
  77. //
  78. // Arguments:
  79. //
  80. // HANDLE hNdsRdr - A handle to the redirector.
  81. // PUNICODE_STRING puTree - The tree name.
  82. // PUNICODE_STRING puContext - The context in that tree.
  83. NTSTATUS
  84. NwNdsGetTreeContext (
  85. IN HANDLE hNdsRdr,
  86. IN PUNICODE_STRING puTree,
  87. OUT PUNICODE_STRING puContext
  88. );
  89. // NwNdsGetTreeContext(HANDLE, PUNICODE_STRING, PUNICODE_STRING)
  90. //
  91. // Get the current context for the specified tree.
  92. //
  93. // Arguments:
  94. //
  95. // HANDLE hNdsRdr - A handle to the redirector.
  96. // PUNICODE_STRING puTree - The tree name.
  97. // PUNICODE_STRING puContext - The context in that tree.
  98. NTSTATUS
  99. NwNdsIsNdsConnection (
  100. IN HANDLE hNdsRdr,
  101. OUT BOOL * pfIsNds,
  102. IN OUT PUNICODE_STRING puTree
  103. );
  104. // NwNdsIsNdsConnection(HANDLE, PUNICODE_STRING)
  105. //
  106. // Get the current context for the specified tree.
  107. //
  108. // Arguments:
  109. //
  110. // HANDLE hNdsRdr - A handle to the redirector.
  111. // BOOL * - Get the boolean value of connection test
  112. // PUNICODE_STRING puTree - The tree name that handle to server
  113. // represents. Caller allocates puTree
  114. // with a buffer big enough to hold
  115. // 48 WCHARs.
  116. //
  117. // Returns: TRUE if hNdsRdr is a handle connected to a server that
  118. // is part of a NDS directory tree. puTree will contain
  119. // the tree name.
  120. // FALSE: if hNdsRdr is not a NDS tree handle.
  121. //
  122. // Browsing and Navigating support.
  123. //
  124. NTSTATUS
  125. NwNdsResolveName (
  126. IN HANDLE hNdsTree,
  127. IN PUNICODE_STRING puObjectName,
  128. OUT DWORD *dwObjectId,
  129. OUT PUNICODE_STRING puReferredServer,
  130. OUT PBYTE pbRawResponse,
  131. IN DWORD dwResponseBufferLen
  132. );
  133. // NwNdsResolveName(HANDLE, PUNICODE_STRING, PDWORD)
  134. //
  135. // Resolve the given name to an NDS object id. This utilizes
  136. // NDS verb 1.
  137. //
  138. // There is currently no interface for canonicalizing names.
  139. // This call will use the default context if one has been set
  140. // for this NDS tree.
  141. //
  142. // puReferredServer must point to a UNICODE_STRING with enough
  143. // space to hold a server name (MAX_SERVER_NAME_LENGTH) *
  144. // sizeof( WCHAR ).
  145. //
  146. // If dwResponseBufferLen is not 0, and pbRawResponse points
  147. // to a writable buffer of length dwResponseBufferLen, then
  148. // this routine will also return the entire NDS response in
  149. // the raw response buffer. The NDS response is described
  150. // by NDS_RESPONSE_RESOLVE_NAME.
  151. //
  152. // Arguments:
  153. //
  154. // HANDLE hNdsTree - The name of the NDS tree that we are interested in looking into.
  155. // PUNICODE_STRING puObjectName - The name that we want resolved into an object id.
  156. // DWORD *dwObjectId - The place where we will place the object id.
  157. // BYTE *pbRawResponse - The raw response buffer, if desired.
  158. // DWORD dwResponseBufferLen - The length of the raw response buffer.
  159. NTSTATUS
  160. NwNdsList (
  161. IN HANDLE hNdsTree,
  162. IN DWORD dwObjectId,
  163. OUT DWORD *dwIterHandle,
  164. OUT BYTE *pbReplyBuf,
  165. IN DWORD dwReplyBufLen
  166. );
  167. // NwNdsList(HANDLE, DWORD, PDWORD, PBYTE, DWORD, PDWORD)
  168. //
  169. // List the immediate subordinates of an object. This utilizes
  170. // NDS verb 5.
  171. //
  172. // Arguments:
  173. //
  174. // HANDLE hNdsTree - The handle to the tree that we are interested in.
  175. // DWORD dwObjectId - The object that we want to list.
  176. // DWORD *dwIterHandle - The iteration handle to be used in continuing
  177. // the request if the buffer is not large enough for the entire
  178. // list of subordinates.
  179. // BYTE *pbReplyBuf - The buffer where the raw reply will be placed.
  180. // DWORD dwReplyBufLen - The length of the raw reply buffer.
  181. NTSTATUS
  182. NwNdsReadObjectInfo(
  183. IN HANDLE hNdsTree,
  184. IN DWORD dwObjectId,
  185. OUT PBYTE pbReplyBuf,
  186. IN DWORD dwReplyBufLen
  187. );
  188. // NwNdsReadObjectInfo(PUNICODE_STRING, DWORD, PBYTE, DWORD)
  189. //
  190. // Given an object id, this gets the basic info for the object. This
  191. // utilizes NDS verb 2. The reply buffer should be large enough to
  192. // hold a DS_OBJ_INFO struct and the text of the two unicode strings.
  193. //
  194. // Arguments:
  195. //
  196. // HANDLE hNdsTree - The tree that we want to look in.
  197. // DWORD dwObjectId - The object id that we want to learn about.
  198. // BYTE *pbReplyBuf - The space for the reply.
  199. // DWORD dwReplyBufLen - The length of the reply buffer.
  200. NTSTATUS
  201. NwNdsReadAttribute (
  202. IN HANDLE hNdsTree,
  203. IN DWORD dwObjectId,
  204. IN DWORD *dwIterHandle,
  205. IN PUNICODE_STRING puAttrName,
  206. OUT BYTE *pbReplyBuf,
  207. IN DWORD dwReplyBufLen
  208. );
  209. // NwNdsReadAttribute(HANDLE, DWORD, PDWORD, PUNICODE_STRING, PBYTE, DWORD)
  210. //
  211. // Read the requested attribute from the listed object.
  212. // This utilizes NDS verb 3.
  213. //
  214. // Arguments:
  215. //
  216. // HANDLE hNdsTree - The tree that we want to read from.
  217. // DWORD dwObjectId - The object that we want to read from.
  218. // DWORD *dwIterHandle - The iteration handle.
  219. // PUNICODE_STRING puAttrName - The name of the attribute.
  220. // BYTE *pbReplyBuf - The buffer to hold the response.
  221. // DWORD deReplyBufLen - The length of the reply buffer.
  222. NTSTATUS
  223. NwNdsOpenStream (
  224. IN HANDLE hNdsTree,
  225. IN DWORD dwObjectId,
  226. IN PUNICODE_STRING puStreamName,
  227. IN DWORD dwOpenFlags,
  228. OUT DWORD *pdwFileLength
  229. );
  230. // NwNdsOpenStream(HANDLE, DWORD, PBYTE, DWORD)
  231. //
  232. // Open a file handle to the stream listed.
  233. // This utilizes NDS verb 27.
  234. //
  235. // Arguments:
  236. //
  237. // HANDLE hNdsTree - The handle to the NDS tree that we are interested in.
  238. // DWORD dwObjectId - The object id that we want to query.
  239. // PUNICODE_STRING puStreamName - The name of the stream that we want to open.
  240. // DWORD dwOpenFlags - 1 for read, 2 for write, 3 for read/write.
  241. // DWORD *pdwFileLength - The length of the file stream.
  242. NTSTATUS
  243. NwNdsGetQueueInformation(
  244. IN HANDLE hNdsTree,
  245. IN PUNICODE_STRING puQueueName,
  246. OUT PUNICODE_STRING puHostServer,
  247. OUT PDWORD pdwQueueId
  248. );
  249. // NwNdsGetQueueInformation(HANDLE, PUNICODE_STRING, PUNICODE_STRING, PDWORD)
  250. //
  251. // Arguments:
  252. //
  253. // HANDLE hNdsTree - The handle to the NDS tree that knows about the queue.
  254. // PUNICODE_STRING puQueueName - The ds path to the queue that we want.
  255. // PUNICODE_STRING puHostServer - The host server for this queue.
  256. // PDWORD pdwQueueId - The queue id for this queue on this server.
  257. NTSTATUS
  258. NwNdsGetVolumeInformation(
  259. IN HANDLE hNdsTree,
  260. IN PUNICODE_STRING puVolumeName,
  261. OUT PUNICODE_STRING puHostServer,
  262. OUT PUNICODE_STRING puHostVolume
  263. );
  264. // NwNdsGetVoluemInformation(HANDLE, PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING)
  265. //
  266. // Arguments:
  267. //
  268. // HANDLE hNdsTree - The handle to the NDS tree that knows about the volume.
  269. // PUNICODE_STRING puVolumeName - The ds path to the volume that we want.
  270. // PUNICODE_STRING puHostServer - The host server for this nds volume.
  271. // PUNICODE_STRING puHostVolume - The host volume for this nds volume.
  272. //
  273. // User mode fragment exchange.
  274. //
  275. NTSTATUS
  276. _cdecl
  277. FragExWithWait(
  278. IN HANDLE hNdsServer,
  279. IN DWORD NdsVerb,
  280. IN BYTE *pReplyBuffer,
  281. IN DWORD pReplyBufferLen,
  282. IN OUT DWORD *pdwReplyLen,
  283. IN BYTE *NdsRequestStr,
  284. ...
  285. );
  286. NTSTATUS
  287. _cdecl
  288. ParseResponse(
  289. PUCHAR Response,
  290. ULONG ResponseLength,
  291. char* FormatString,
  292. ...
  293. );
  294. int
  295. _cdecl
  296. FormatBuf(
  297. char *buf,
  298. int bufLen,
  299. const char *format,
  300. va_list args
  301. );
  302. //
  303. // Change password support.
  304. //
  305. NTSTATUS
  306. NwNdsChangePassword(
  307. IN HANDLE hNwRdr,
  308. IN PUNICODE_STRING puTreeName,
  309. IN PUNICODE_STRING puUserName,
  310. IN PUNICODE_STRING puCurrentPassword,
  311. IN PUNICODE_STRING puNewPassword
  312. );
  313. #ifdef __cplusplus
  314. } // extern "C"
  315. #endif