Mikrotik API

Hi,

I’m creating an app to connect Mikrotik user manager,

i can add user with this command :

/tool/user-manager/user/add
=customer=admin
=username=u11
=password=u11
=location=park
=first-name=fname
=last-name=lname
=shared-users=1
=copy-from=IT

only when i add a user with command i got the “id”

for remove or change the user information such as password, and other information i need “id”

how can i find the “id” of user

Here is the remove and change mikrotik command :

---- ***** User Manager → Delete User

/tool/user-manager/user/remove
=.id=*88


---- ***** User Manager → SET User


/tool/user-manager/user/set
=.id=*14
=username=somenewuser
=password=somenewpassword

In menus where there’s a name, you don’t need to find an ID. You can use the name instead. This is certainly the case with the user manager’s “user” menu, so f.e.

/tool/user-manager/user/set
=.id=u11
=username=somenewuser
=password=somenewpassword

In menus where there’s no name, you can use the “print” command to get a list of all IDs in a menu. You can add a query to it to find a specific item’s ID, and you can add the “.proplist” argument to limit the returned properties to just the ID, e.g.

/tool/user-manager/user/print
=.proplist=.id
?username=u11

will return

!re
=.id=*14

!done

tnx, it work.

mk.Send(“/tool/user-manager/user/add”, False)
mk.Send(“=customer=admin”, False)
mk.Send(“=username=” & tb_name.Text & “”, False)
mk.Send(“=password=” & tb_password.Text & “”, False)
mk.Send(“=shared-users=3”, False)
mk.Send(“=;create-and-activate-profile=” & tb_name.Text & “”, False)
mk.Send(“=customer=admin”, False)
mk.Send(“=profile = general”, True)

i am try to add user form visual basic API from above code. but result of the above code is unknown parameter. but if am i use following code i can create user successfully. any one can help me..?

mk.Send(“/tool/user-manager/user/add”, False)
mk.Send(“=customer=admin”, False)
mk.Send(“=username=” & tb_name.Text & “”, False)
mk.Send(“=password=” & tb_password.Text & “”, False)
mk.Send(“=copyfrom=0”, true)

If your code is literally a “copy&paste”, then the line

mk.Send("=;create-and-activate-profile=" & tb_name.Text & "", False)

is where the problem is at.

Remove the “;” at the start there.

Also… Isn’t “create-and-active-profile” a separate command altogether?

actually i want to send following win box terminal code from visual basic
add customer=admin username=name passwor
d=password;create-and-activate-profile name customer=admin profile=general

Right. In Winbox’s terminal, those are two different commands. Therefore, you need to send two separate sentences, e.g.

mk.Send("/tool/user-manager/user/add", False)
mk.Send("=customer=admin", False)
mk.Send("=username=" & tb_name.Text & "", False)
mk.Send("=password=" & tb_password.Text & "", False)
mk.Send("=shared-users=3", True)

mk.Send("/tool/user-manager/user/create-and-activate-profile", False)
mk.Send("=numbers=" & tb_name.Text & "", False)
mk.Send("=customer=admin", False)
mk.Send("=profile = general", True)

i tried above code. that create user, but not assign profile “general” to users.

Remove the spaces in the profile line:

mk.Send("=profile=general", True)

ok done. now i want to develop this code to create user batch

i want to view available user profile when i load the api. it is better if i can insert profiles into combo box item

Hi having some problem with my code

mikrotik.Send(“/tool/user-manager/user/create-and-activate-profile”);
mikrotik.Send(“=numbers=user1”);
mikrotik.Send(“=customer=admin”);
mikrotik.Send(“=profile=1Mbps”,true );
this is not assigning any profile

Please help.

I am using the Java api to connect to my Mikrotik and change the users password. I can connect to the router but not run the command. I have tried multiple different ways and tried to learn how to write the commands in the api but without any luck. Is anyone willing to help me figure out how to write the code?