Community discussions

MikroTik App
 
User avatar
ohara
Member
Member
Topic Author
Posts: 387
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

VB.net API new login procedure

Thu Oct 10, 2019 10:17 pm

Hi, can someone please help me how to modify this piece of VB.Net code to make it compatible with the new API login procedure? I am using ROS 6.45.6 and I can't figure it out. Many thanks.

Code: Select all

Public Function Login(ByVal user As String, ByVal pass As String) As Boolean
Send("/login", True)
Dim hash = Read()(0).Split(New String() {"ret="}, StringSplitOptions.None)(1)
Send("/login")
Send("=name=" + user)
Send("=response=00" + EncodePassword(pass, hash), True)
Dim res = Read()
If (res(0) = "!done") Then Return True Else Return False
End Function

SOURCE: https://wiki.mikrotik.com/wiki/API_in_VB_dot_NET

Login method post-v6.43:

/login
=name=admin
=password=
!done

Now client sends username and password in first message.
Password is sent in plain text.
in case of error, reply contains =message=error message.
In case of successful login client can start to issue commands.
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: VB.net API new login procedure  [SOLVED]

Thu Oct 10, 2019 10:24 pm

Try this:

		Send("/login")
		Send("=name=" + user)
		Send("=password=" + pass, True)

(Alternatively, use the tik4net package: viewtopic.php?f=9&t=99954)
 
User avatar
ohara
Member
Member
Topic Author
Posts: 387
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: VB.net API new login procedure

Thu Oct 10, 2019 10:48 pm

Thank you nescafe, that worked. I owe you something!

Code: Select all

Public Function Login(ByVal user As String, ByVal pass As String) As Boolean

Send("/login")
Send("=name=" + user)
Send("=password=" + pass, True)

Dim res = Read()
If (res(0) = "!done") Then Return True Else Return False

End Function
 
lucasverolo
just joined
Posts: 1
Joined: Thu Oct 31, 2019 6:16 pm

Re: VB.net API new login procedure

Thu Oct 31, 2019 7:18 pm

Hi, I need to know, if you can help me in the new login procedure in version 6.45.7 for vb6 for api. Thank you.

Who is online

Users browsing this forum: qwertykolea and 59 guests