On Tuesday 26 November 2013 14:58:07 Clément OUDOT wrote:
> 2013/11/26 Roman Inflianskas <[email protected]>:
> > Hi!
> >
> > Thanks for creating useful project named "Self Service Password".
> >
> > I admin small business server. We have Redmine and Mercurial installed. 
> > Both are using LDAP for user authentication. To ease administration I wrote 
> > small script (with Python 3) on top of ldapscripts to add users. I want 
> > user to specify his own password. For that purpose I want my script to send 
> > Self Service Password token for changing password in the same letter in 
> > which I congratulate him on account creation. How can I retrieve token? Is 
> > there function in PHP pages of Self Service Password that I can call to 
> > retrieve token? Can I use special formed URL for that purpose?
> 
> 
> Hi,
> 
> thanks for your message.
> 
> Unfortunately, Self Service Password is really web oriented, and do
> not allows request from a script. We use POST and GET parameters, and
> PHP session backend. You can just script HTTP requests that will reach
> SSP pages, simulating a Web browser. You then need to parse HTML code
> to get the token.
> 
> Clément.
Hi.

I forgot to answer my own question (for future googlers).

Here is the very simple code written in python2 for simulating web browser and 
requesting token:
                                                                                
                                                                                
        
from mechanize import ParseResponse, urlopen, urljoin

def reset_password(url, login, mail):
    response = urlopen(urljoin(url, "index.php?action=sendtoken"))
    forms = ParseResponse(response, backwards_compat=False)
    form = forms[0]
    form['login'] = login
    form['mail'] = mail
    urlopen(form.click())

-- 
Regards, Roman Inflianskas
_______________________________________________
ltb-users mailing list
[email protected]
http://lists.ltb-project.org/listinfo/ltb-users

Reply via email to