# Activedirectory change password

**URL:** <https://www.ruby-forum.com/t/activedirectory-change-password/80829>\
**Category:** Rails\
**Created:** [December 31, 2006, 12:40am UTC](https://www.ruby-forum.com/t/activedirectory-change-password/80829 "2006-12-31T00:40:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [December 31, 2006, 12:40am UTC](https://www.ruby-forum.com/t/activedirectory-change-password/80829/1 "2006-12-31T00:40:44Z")

</div>

Hi all, I’m currently using Jusin Mecham’s activedirectory-0.9.3  
plugin. Does anyone know how can I implement change password against  
active directory? as a matter of fact, is there a way to update all  
other info in active directory in rails?

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [January 2, 2007, 1:24am UTC](https://www.ruby-forum.com/t/activedirectory-change-password/80829/2 "2007-01-02T01:24:28Z")

</div>

paul wrote:

> Hi all, I’m currently using Jusin Mecham’s activedirectory-0.9.3  
> plugin. Does anyone know how can I implement change password against  
> active directory? as a matter of fact, is there a way to update all  
> other info in active directory in rails?

A change\_password method has been added to the ActiveDirectory::User  
class in the activedirectory svn repository:

[http://code.google.com/p/ruby-activedirectory/source](http://code.google.com/p/ruby-activedirectory/source)

I don’t think there is any way to change other attributes yet.

–  
Phil Ross  
[http://tzinfo.rubyforge.org/](http://tzinfo.rubyforge.org/) – DST-aware timezone library for Ruby

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [January 17, 2007, 10:01am UTC](https://www.ruby-forum.com/t/activedirectory-change-password/80829/3 "2007-01-17T10:01:31Z")

</div>

Hi Phil, Just manage to see your message. I tried out your code today  
and got the following message, any idea?

> > a.change\_password(‘mynewpass’)  
> > LDAP::ResultError: No Such Attribute  
> > from  
> > c:/ruby/lib/ruby/gems/1.8/gems/activedirectory-1.0.0/lib/active\_di  
> > ectory/user.rb:153:in `modify' from c:/ruby/lib/ruby/gems/1.8/gems/activedirectory-1.0.0/lib/active_di ectory/user.rb:153:in`change\_password’  
> > from (irb):6

your code is

def change\_password(new\_password)  
hash = {  
‘unicodePwd’ =\> [  
ActiveDirectory::Datatypes::UnicodePassword.to\_remote(new\_password) ],  
‘lockoutTime’ =\> [‘0’],  
‘userAccountControl’ =\> [UAC\_NORMAL\_ACCOUNT.to\_s]  
}  
Base.connection.raw.modify(dn,hash)  
end
