Community discussions

MikroTik App
 
twinsandme3
just joined
Topic Author
Posts: 12
Joined: Fri Sep 02, 2011 11:21 am

How to change UM's password through API?

Mon Jan 30, 2012 3:33 pm

For example,i have some users in UM,i want to change the user's password,in Telnet i can use this script to change user "test" password from "test" to "123456"
but i don't know how to do through the API
/tool user-manager user set [/tool user-manager user find name ="test"] password="123456"
Api1.JPG
Api2.JPG
the API’s program has already working

can be displayed User information
Api3.JPG
You do not have the required permissions to view the files attached to this post.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: How to change UM's password through API?

Mon Jan 30, 2012 3:42 pm

you always can try with python API to try to get the results without any intervention of the software in the output, so we could see exactly what command you send and what is the result.

also, you will have to do that in 2 commands, 1 to get the correct ID of the entry that has to be changed and then issue set for that id you got previously.
 
twinsandme3
just joined
Topic Author
Posts: 12
Joined: Fri Sep 02, 2011 11:21 am

Re: How to change UM's password through API?

Mon Jan 30, 2012 4:14 pm

here is the original output when i send "/tool/user-manager/user/print"
!re=
.id=*1
=customer=admin
=name=123456
=actual-profile=3M鏃犻檺鏃
?password=123456
=shared-users=1
=wireless-psk=
=wireless-enc-key=
=wireless-enc-algo=none
=uptime-used=2d17:24:17
=download-used=7873923601
=upload-used=213002051
=last-seen=jan/17/2012 16:26:01
=active=false
=incomplete=false
=disabled=false

!re=
.id=*3
=customer=admin
=name=test
=actual-profile=4M鍖呮湀
=password=123456
=first-name=娴嬭瘯鐢ㄦ埛
=last-name=娴嬭瘯鐢ㄦ埛
=phone=13790XXXXXX
=location=鏌愯鏌愬贩325鍙
?shared-users=1
=wireless-psk=
=wireless-enc-key=
=wireless-enc-algo=none
=uptime-used=05:35:56
=download-used=301343201
=upload-used=35102990
=last-seen=jan/21/2012 11:28:52
=active=false
=incomplete=false
=disabled=false

!done
the program is fine,but i just want to change the Password in UM's user
Api4.JPG
You do not have the required permissions to view the files attached to this post.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How to change UM's password through API?

Mon Jan 30, 2012 5:17 pm

The first request - the "print" command - needs to be accompanied with an appropriate query. In your case, the query would be
?name=test
Instead of showing us the GUI, show us the code behind it, as this is a code issue - the ID needs to be parsed out from the response, and either stored in a variable, or passed directly at the "set" command.
 
twinsandme3
just joined
Topic Author
Posts: 12
Joined: Fri Sep 02, 2011 11:21 am

Re: How to change UM's password through API?

Tue Jan 31, 2012 6:18 am

/tool/user-manager/user/set
=.id=*3
=password=12
that's right