[Win32utils-devel] win32-etc-0.2.2 testing wanted

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Fri Mar 12 23:52:48 EST 2004


Hi,
----- Original Message ----- 
From: <win32utils-devel at rubyforge.org>
To: <win32utils-devel at rubyforge.org>
Sent: Friday, March 12, 2004 1:12 PM
Subject: [Win32utils-devel] win32-etc-0.2.2 testing wanted


>
> >C:\win32utils\win32-etc\test>ruby test_admin.rb
> >test_admin.rb:51: syntax error
> >                :flags       => 0,
> >                 ^
> >test_admin.rb:53: syntax error
>
> No, that's just a typo.  Here's what happens if I just try this:
>
> Etc::Admin.configure_user(
>    :user_name => user,
>    :description => "Total loser - delete asap"
> )
>
> C:\eclipse\workspace\win32-etc-0.2.2\test>ruby test_admin.rb -k foo
> VERSION: 0.2.2
> test_admin.rb:48:in `configure_user': unknown error: 87
> (Win32::Etc::AdminError)
>
> 87 is "bad parameter".  I didn't actually track down *which* parameter
(uh,
> still trying to figure that out) but knowing that won't make me less
> confused (will it?).
>
> Any ideas?
>
> Dan
>
There was two bugs in etc.c

First, line 664 in function etc_add_user

   switch(rv)

should be

   switch(r)

Second, related USER_INFO_1 structure in etc_config_user
Try with LPUSER_INFO_1 like this:
========================================================
static VALUE etc_config_user(VALUE mod, VALUE rbHash){
   LPUSER_INFO_1 puiUser = NULL;
   LPCWSTR lpServerName = NULL;
   LPCWSTR lpUser = NULL;
   VALUE rbVal;
   DWORD dwLevel = 1;
   NET_API_STATUS nStatus;
   LPDWORD index = 0;

   Check_Type(rbHash,T_HASH);
   rbHash = normalize(rbHash,"user");

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("user_name"))) != Qnil){
      Check_Type(rbVal,T_STRING);
      lpUser = AllocWideLString(rbVal);
   }
   else{
      rb_raise(rb_eStandardError,"No user name provided");
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("host"))) != Qnil){
      Check_Type(rbVal,T_STRING);
      lpServerName = AllocWideLString(rbVal);
   }

   // Get the current info, change whatever is set by programmer
   nStatus = NetUserGetInfo(
      NULL,
      lpUser,
      dwLevel,
      (LPBYTE*)&puiUser
   );

   if(NERR_Success != nStatus){
      handle_user_error(nStatus);
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("password"))) != Qnil){
      puiUser->usri1_password = AllocWideLString(rbVal);
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("home_dir"))) != Qnil){
      Check_Type(rbVal,T_STRING);
      puiUser->usri1_home_dir = AllocWideLString(rbVal);
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("description"))) != Qnil){
      puiUser->usri1_comment = AllocWideLString(rbVal);
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("flags"))) != Qnil){
      puiUser->usri1_flags = NUM2INT(rbVal);
      // The docs say this value must be set, so I'll do it automatically
      puiUser->usri1_flags |= UF_SCRIPT;
   }

   if( (rbVal = rb_hash_aref(rbHash,rb_str_new2("script_path"))) != Qnil){
      puiUser->usri1_script_path = AllocWideLString(rbVal);
   }

   nStatus = NetUserSetInfo(
      NULL,
      lpUser,
      dwLevel,
      (LPBYTE)(puiUser),
      index
   );

   if(NERR_Success != nStatus){
      handle_user_error(nStatus);
   }

   return Qtrue;
}
======================================================

Regards,

Park Heesob




More information about the win32utils-devel mailing list