[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem with OLE, ADSI and adding a local user account

Berger, Daniel

3/31/2005 1:04:00 AM

Hi all,

Ruby 1.8.2
Windows XP Pro

I'm trying to add a local user account with the following code:

# adsi_test.rb
require "socket"
require "win32ole"

host = Socket.gethostname

adsi = WIN32OLE.connect("WinNT://#{host},Computer")
u = adsi.create("user","bar")
u.setpassword("999fooBarQ2343")
u.setinfo # Boom!

It chokes on the setinfo call with this:

win32.rb:345:in `method_missing': setinfo (WIN32OLERuntimeError)
OLE error code:800708C5 in <Unknown>
<No Description>
HRESULT error code:0x80020009
Exception occurred. from win32.rb:345:in `add_user'
from win32.rb:385

Where "800708C5" is the error code for a password policy violation,
which generally means it's too short or has been used previously.
However, no matter what password I try, I get the same error.

What am I doing wrong?

Regards,

Dan



1 Answer

dave.burt

3/31/2005 1:42:00 AM

0

>From MSDN, quoted at
http://www.dotnet247.com/247reference/msgs/26/1...

----------------------------------------------------------------------
For the LDAP provider, the user account must have been created and
stored in the underlying directory using IADs::SetInfo before
IADsUser::SetPassword is called.

The WinNT provider, however, allows you to set the password on a newly
created user object prior to calling SetInfo