hi ,

      i am using db2 udb 7.1 on winNT 4.0 .. 
      Iam not able to run a external C stored procedure   ... 
  i want to add a new user to winNT using a stored procedure for that i
created a dll addnewuser
  and placed it in  sqllib\fuction directory .. when ever i run the stored
procedure i get the fooliwng message

 " addnewuser DLL is loaded but function wmain could not be executed " 
  some one help how to make it work properly 
  
 or else  help me with any small stored procedure example  that make use of
this kind library way..

  
thanks,
srikanth

   CREATE PROCEDURE test( in servername char(12), in username char(10))
      DYNAMIC RESULT SETS 0
      LANGUAGE C 
      PARAMETER STYLE GENERAL
      NO DBINFO
      FENCED
       PROGRAM TYPE MAIN
      EXTERNAL NAME 'addnewuser!wmain'


#ifndef UNICODE
#define UNICODE
#End If

#include <stdio.h>
#include <windows.h>
#include <lm.h>

int wmain(int argc, wchar_t *argv[])
{
   USER_INFO_1 ui;
   DWORD dwLevel = 1;
   DWORD dwError = 0;
   NET_API_STATUS nStatus;

   if (argc != 3)
   {
      fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
      exit(1);
   }
   
   ui.usri1_name = argv[2];
   ui.usri1_password = argv[2];
   ui.usri1_priv = USER_PRIV_USER;
   ui.usri1_home_dir = NULL;
   ui.usri1_comment = NULL;
   ui.usri1_flags = UF_SCRIPT;
   ui.usri1_script_path = NULL;
   
   nStatus = NetUserAdd(argv[1],
                        dwLevel,
                        (LPBYTE)&ui,
                        &dwError);
   
   if (nStatus == NERR_Success)
      fwprintf(stderr, L"User %s has been successfully added on %s\n",
               argv[2], argv[1]);
   
   Else
      fprintf(stderr, "A system error has occurred: %d\n", nStatus);

   return 0;
}



     
     

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

Reply via email to