Community discussions

MikroTik App
 
jmaria62
just joined
Topic Author
Posts: 10
Joined: Wed Nov 26, 2014 2:39 pm

delete all users usermanager

Mon Dec 01, 2014 2:52 pm

Hi,
I need to make a routine in .net to synchronize our user's table with the users into user manager.

I think one solution is delete all the users from user manager and after insert one by one.

What do you think?

It's possible to send one command from .net to delete all the records?

Is there another kind of solution?

Thank you and excuse my english
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: delete all users usermanager

Mon Dec 08, 2014 10:40 pm

I think one solution is delete all the users from user manager and after insert one by one.
That would probably be the easiest as long as you don't need to keep any of the existing usermanager users.
It's possible to send one command from .net to delete all the records?
I don't know about .net, but you can delete all users from the router by running this command in the console:
/tool user-manager user remove [find]
I need to make a routine in .net to synchronize our user's table with the users into user manager.
Does this need to continue to be synchronized as users are added/removed from .net db? Or do you only need to do this synchronization only one time?

If it's only one time, I would export an excel or text file list of all the users from .net, and then edit the file using find/replace to get it into the format of:
/tool user-manager user add name=userName customer=admin etc...
Then, you can copy/paste the code directly into the router and add the users.
 
jmaria62
just joined
Topic Author
Posts: 10
Joined: Wed Nov 26, 2014 2:39 pm

Re: delete all users usermanager

Mon Dec 15, 2014 11:26 am

Hi, I need to synchronize the tables periodically , maybe every day.
The code I'm triying to delete all the users is:
mk.Send("/tool/user-manager/user/remove [find]", False)
mk.Send("=customer=admin", True)
and the response from mikrotik is
!trap=message=no such command!


Any idea?

Thank you
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: delete all users usermanager

Mon Dec 15, 2014 10:56 pm

With the API, you will need to get all items and then loop through and remove them. Something like this:
http://forum.mikrotik.com/viewtopic.php ... 74#p239737, except this is in different API client.

This .net code looks like it loops through items, might be helpful:
http://forum.mikrotik.com/viewtopic.php ... 10#p400763
 
jmaria62
just joined
Topic Author
Posts: 10
Joined: Wed Nov 26, 2014 2:39 pm

Re: delete all users usermanager

Tue Dec 16, 2014 9:37 am

Hi, can you say me how convert the next command in .net code?

/tool user-manager user remove [find]

I not know how to use the query "[find]" into the vb .net code.

For example I try to send this code but it not works

mk.Send("/tool/user-manager/user/remove", False)
mk.Send("=[find]=", False)
mk.Send("=customer=admin", True)

Can you help me?

Thank you.