MK mikrotik = new MK(“your ip here”);
if (mikrotik.Login(“admin”,“password”))
{
mikrotik.Send(“/tool/user-manager/user/add”);
mikrotik.Send(“=customer=admin”);
mikrotik.Send(“=username=test”);
mikrotik.Send(“=password=testtest”, true);
string result = mikrotik.Read();
}
Focus on changes in virsons
like name, username
and in actvate profile you must change user to numbers
and if you want to use username in actvate you must use like this code
in new virson like 6.33 and up
this.mikrotik.Send(“/tool/user-manager/user/create-and-activate-profile”);
this.mikrotik.Send(“=customer=admin”);
this.mikrotik.Send(“=numbers=test”);
this.mikrotik.Send(“=profile=profilename”, true);and in virson like 5.25
this.mikrotik.Send(“/tool/user-manager/user/create-and-activate-profile”);
this.mikrotik.Send(“=customer=admin”);
this.mikrotik.Send(“=user=test”);
this.mikrotik.Send(“=profile=profilename”, true);
hi pal . .
i have another problem //
i use this code to find specific user :
Console.Write("\n\n\t\t Write Your Username : ");
string name = Console.ReadLine();
mikrotik.Send("/tool/user-manager/user/print");
mikrotik.Send("?username="+name, true);
foreach (string h in mikrotik.Read())
{
Console.WriteLine( h);
}
it works . .
but i want to display some part of info . .
for ex i want to display just username not all the information of that user . .
what should i do ?
how should i filter “h” to display specific info ?
you must define what info you want
like this
mikrotik.Send(“/tool/user-manager/user/print”);
mikrotik.Send(“?username=”+name);
mikrotik.Send(“=.proplist=.id,username,password,actual-profile”, true);
hey bro , you are my hero ))))
i have another question . .
Stream connection;
TcpClient con;
public MK(string ip)
{
con = new TcpClient();
con.Connect(ip, 8728);
connection = (Stream)con.GetStream();
}
with above code :
when i enter wrong ip my program goes crashing . .
i wanna when i enter wrong ip it show message that ip is wrong . .
what should i do with this code ?
i think the message for all wrong is one
for wrong ip , or port, or username and password ( one message for wrong in connection )
so you just use one message for any problem in connect.
i think it is no important for this
Hello bro…, I have a problem when registering the user, the problem is that I run the code twice, it only registers the user’s name and the password does not register what I can do to correct that error
MK mikrotik = new MK(“10.10.0.254”);
if (!mikrotik.Login(“itamar”, “12345678”))
{
Console.WriteLine(“No se pudo entrar a la cuenta”);
Console.ReadKey();
mikrotik.Close();
return;
}
mikrotik.Send(“/ip/hotspot/user/remove”,false);
mikrotik.Send(“=name=n”, false);
mikrotik.Send(“=password=n”, true);
mikrotik.Send(“=profile=profile1=”, true);
Console.WriteLine(“usuario creado”);
foreach (string h in mikrotik.Read())
{
Console.WriteLine(h);
}
Console.ReadKey();
Hello sister, I have a problem when registering the user, the problem is that I run the code twice, it only registers the user’s name and the password does not register what I can do to correct that error
MK mikrotik = new MK(“10.10.0.254”);
if (!mikrotik.Login(“itamar”, “12345678”))
{
Console.WriteLine(“No se pudo entrar a la cuenta”);
Console.ReadKey();
mikrotik.Close();
return;
}
mikrotik.Send(“/ip/hotspot/user/remove”,false);
mikrotik.Send(“=name=n”, false);
mikrotik.Send(“=password=n”, true);
mikrotik.Send(“=profile=profile1=”, true);
Console.WriteLine(“usuario creado”);
foreach (string h in mikrotik.Read())
{
Console.WriteLine(h);
}
Console.ReadKey();