home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / AUTHEN / README
Encoding:
Text File  |  1989-12-11  |  8.3 KB  |  273 lines

  1.                        authen Example
  2.  
  3.  
  4.  
  5.  
  6. 1.  Environment
  7.  
  8. This example is designed to be built and executed on a PC
  9. that runs DOS, the Microsoft C Compiler and utilities, and
  10. that uses the NetWare network library.
  11.  
  12.  
  13.  
  14.  
  15. 2.  Overview
  16.  
  17. This example demonstrates how a simple authentication
  18. mechanism can be added to the code generated by NetWare RPC.
  19.  
  20.  
  21.  
  22.  
  23. 3.  Keywords
  24.  
  25. authentication, Hooks, Traps, RPC macros, validation state,
  26. import statement
  27.  
  28.  
  29.  
  30.  
  31. 4.  Files
  32.  
  33. Source files for this example reside in the following sub-
  34. directories:
  35.  
  36. server:
  37.  
  38.      Contains code and build procedures for the server part
  39.      of this distributed application.  The server consists
  40.      of the server control procedure, which is provided with
  41.      the product distribution, the dispatcher procedure and
  42.      server stub routines, which are generated by the RPC
  43.      Compiler, and the remote procedures, which are provided
  44.      with this example.
  45.  
  46.      rproc.c       remote procedure application code
  47.  
  48.      server.mk     makefile for building the server
  49.  
  50.      serv_def.h    include file with macro definitions for
  51.                    the server control procedure
  52.  
  53. client:
  54.  
  55.      Contains code and build procedures for the client part
  56.      of this distributed application.  The client consists
  57.      of the client main program and any associated routines,
  58.      which are provided with this example, and the client
  59.      stubs, which are generated by the RPC compiler.
  60.  
  61.      client.c      client application code (main program)
  62.  
  63.      client.mk     makefile for building the client
  64.  
  65. common:
  66.  
  67.      Contains the RPC interface specification used by the
  68.      RPC compiler to create the client and server stubs.
  69.      The RPC interface specification imports the authen RPC
  70.      specification file to provide an authentication
  71.      mechanism for the server.
  72.  
  73.      authen.rpc    RPC interface specification for this
  74.                    example
  75.  
  76. authen/common:
  77.  
  78.      Contains the RPC interface specification consisting of
  79.      client and server stub Hooks and Traps code which
  80.      implements an authentication mechanism.
  81.  
  82.      authen_i.rpc  authen RPC specification
  83.  
  84. authen/client
  85.  
  86.      Contains the build procedure for compiling the
  87.      authen_i.rpc RPC specification.
  88.  
  89.      client_i.mk   makefile for building the authen_i
  90.                    include file and the RPC code file (which
  91.                    can be ignored in this case) for the
  92.                    client
  93.  
  94. authen/server
  95.  
  96.      Contains the build procedure for compiling the
  97.      authen_i.rpc RPC specification.
  98.  
  99.      server_i.mk   makefile for building the authen_i
  100.                    include file and the RPC code file (which
  101.                    can be ignored in this case) for the
  102.                    server
  103.  
  104.  
  105.  
  106.  
  107. 5.  Network Configuration
  108.  
  109. Before you can run this example, you may have to ask your
  110. system administrator to configure your system specifically
  111. for your needs.  The required configuration is described in
  112. the file: ..\..\READSPX
  113.  
  114.  
  115.  
  116.  
  117. 6.  Server Name
  118.  
  119. As distributed, the server for this example will register
  120. under the name "example".  However, it is strongly suggested
  121. that a unique server name be assigned to this example before
  122. it is built.
  123.  
  124. A unique server name will prevent two or more users from
  125. invoking a server process using the same server name.
  126. Choose a server name not likely to be selected by someone
  127. else.  For example, use your user or login name.
  128.  
  129. The server name must be changed in both the client and the
  130. server, and the SAME name must be used.  To change the
  131. server name for the client program, change to the client
  132. directory (client) and edit the file client.c.  Change the
  133. #define Server_Name statement as follows:
  134.  
  135.       #define Server_Name "example"
  136.           is changed to
  137.       #define Server_Name "myname"
  138.  
  139. To change the server name for the server program, change to
  140. the server directory (server) and edit the file serv_def.h,
  141. which contains the define statements for the server control
  142. procedure.  As with the client program, simply change the
  143. #define Server_Name statement.
  144.  
  145.  
  146.  
  147.  
  148. 7.  Building Client & Server
  149.  
  150. Procedures are included for building the example program.
  151. These procedures assume that your environment is set up as
  152. follows:
  153.  
  154.    - The PATH environment variable must specify the location
  155.      of the RPC Compiler executable files.
  156.  
  157.    - The LIB environment variable must specify the location
  158.      of the RPC runtime libraries.
  159.  
  160.    - The INCLUDE environment variable must specify the
  161.      location of the RPC .h include files.
  162.  
  163.    - The PDUDIR environment variable must specify the
  164.      location of the RPC .rpc files.
  165.  
  166.    - The RPCSCP environment variable must specify the
  167.      location of the RPC server control procedures.
  168.  
  169. The PATH, LIB, and INCLUDE environment variables should be
  170. set in your autoexec.bat file by modifying their current
  171. definitions. The PDUDIR and RPCSCP environment variables can
  172. be set in your autoexec.bat file, or in a local .bat file,
  173. or directly with the "set" command.
  174.  
  175. Since a distributed application runs on two machines, you
  176. must install an executable version of the client or server
  177. on another machine.  If the two machines are identical, you
  178. can build both executables (the client and server) on one
  179. machine and then move one of the executables.  However, if
  180. the two machines are not identical, you must follow the
  181. directions on the other machine for running this example and
  182. build one of the executable programs there (note that the
  183. executable filenames may differ across products).
  184.  
  185. Note that with the Microsoft C Compiler and utilities,
  186. numerous warnings will be generated when executing the
  187. makefiles. For example, you may see a "target does not
  188. exist" or "module not in library" warning. These simply mean
  189. that the file the makefile is currently creating does not
  190. yet exist. Generally, all warnings may be ignored.
  191.  
  192. To build the example program, you simply execute the build
  193. procedures in each subdirectory as follows:
  194.  
  195.   1.  Change to the client directory of the imported file
  196.       (authen/client) and build the client files associated
  197.       with the imported RPC specification file:
  198.  
  199.            make client_i.mk
  200.  
  201.   2.  Change to the server directory of the imported file
  202.       (authen/server) and build the server files associated
  203.       with the imported RPC specification file:
  204.  
  205.            make server_i.mk
  206.  
  207.   3.  Change to the client directory (client) and build the
  208.       client:
  209.  
  210.            make client.mk
  211.  
  212.   4.  Change to the server directory (server) and build the
  213.       server:
  214.  
  215.            make server.mk
  216.  
  217.  
  218.  
  219.  
  220.  
  221. 8.  Running the Distributed Application
  222.  
  223. The server program should be started before the client
  224. program is run.
  225.  
  226. To run the example on two machines, proceed as follows:
  227.  
  228.   1.  Change to the server directory (server) on the machine
  229.       running the server and start the server:
  230.  
  231.            server
  232.  
  233.   2.  Change to the client directory (client) on the machine
  234.       running the client and start the client:
  235.  
  236.            client
  237.  
  238.  
  239.  
  240.  
  241.  
  242. 9.  Description
  243.  
  244. This example demonstrates how a simple authentication
  245. mechanism can be added to the code generated by the RPC
  246. TOOLS.  With this simple authentication check, a server can
  247. confirm that a client has correctly produced an
  248. identification key.  Note that because encryption is not
  249. being used to protect keys, this simple authentication
  250. mechanism is not a secure mechanism.
  251.  
  252. The authentication code is found in an RPC specification
  253. called "authen_i.rpc." This authentication code is added
  254. using Hooks and Traps statements.  Other specifications,
  255. including the one shown in this example, can incorporate the
  256. authentication code by importing "authen_i.rpc."
  257.  
  258. To take advantage of this authentication mechanism a client
  259. must declare and initialize a global variable called
  260. "client_key."
  261.  
  262. Likewise, the server must declare and initialize a global
  263. variable called "server_key." Additionally, the server must
  264. also declare its own global variable called "client_key" for
  265. the temporary storage of the key received from the client.
  266.  
  267. If a client is rejected because the wrong key was used, the
  268. error returned is the INVALID_KEY_ERROR defined within the
  269. "authen_i.rpc" specification.
  270.  
  271. For more information on Hooks and Traps, see the NetWare RPC
  272. User's Manual, "Customizing the RPC Code," Chapter 7.
  273.