# Changing/Setting Passwords in Active Directory

**URL:** <https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094>\
**Category:** Ruby\
**Created:** [August 27, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094 "2007-08-27T16:26:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [August 27, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094/1 "2007-08-27T16:26:42Z")

</div>

I’ve been doing some searching but am not faring so well.

Does anyone know a clean and reliable way to change and or set passwords  
for  
Windows accounts residing in Active Directory?

I’d rather not have to generate a VB script to be run for every user  
account  
created.

Thanks,  
Glen

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [August 27, 2007, 5:19pm UTC](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094/2 "2007-08-27T17:19:47Z")

</div>

On 8/27/07, Glen H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,  
> Glen
> 
> –  
> “Hey brother Christian with your high and mighty errand, Your actions  
> speak  
> so loud, I can’t hear a word you’re saying.”
> 
> -Greg Graffin (Bad Religion)

I think I’m close but something is not working somewhere. This seems to  
be  
the most promising approach but doesn’t work:

require ‘win32ole’  
require ‘Win32API’

adsi = WIN32OLE.connect(“LDAP://cn=#{username},PATH\_TO\_CONTAINER”)

adsi.put(“SetPassword”, “#{password}”)  
this returns nil

adsi.invoke(“SetPassword”, “#{password}”)  
this returns the string given as the password but nothing is changed

The following VB script works just fine:

Set objUser = GetObject \_  
(“LDAP://my values here”)  
objUser.SetPassword “some password”

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [August 27, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094/3 "2007-08-27T17:44:49Z")

</div>

Never mind, figured it out.

I needed to do:

adsi.SetPassword(“password”)

On 8/27/07, Glen H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > account  
> > -Greg Graffin (Bad Religion)
> 
> objUser.SetPassword “some password”
> 
> –  
> “Hey brother Christian with your high and mighty errand, Your actions  
> speak  
> so loud, I can’t hear a word you’re saying.”
> 
> -Greg Graffin (Bad Religion)

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)
