问题描述
因此,我有以下功能可以使用 RouterOS PHP 库为注册用户激活配置文件
public function activateProfile($username)
{
$activationQuery = new Query(
'/tool/user-manager/user/create-and-activate-profile',[
'=user=' . $username,'=customer=admin','=profile=profile1',]
);
$response = $this->query($activationQuery)->read(false);
print("Activating Profile...");
print_r($response);
}
但我一直收到下面的错误消息
Activating Profile...Array ( [0] => !trap [1] => =message=no such command [2] => !done )
解决方法
快速回复
您不能传递属性词 user
,您需要传递标识用户的数字。如documentation 所说,最好先创建然后再创建并激活配置文件。
说明
RouterOS API command words 密切关注 CLI。
你的命令词是/tool/user-manager/user/create-and-activate-profile
。
你的属性词是=user
,=customer
,=profile
。
您可以从 User_Manager 中与 CLI 和 wiki 进行比较,=user= 可用
[admin@106] /tool user-manager user> create-and-activate-profile
<numbers> -- List of item numbers
customer --
profile --
演示
/tool/user-manager/user/add
=customer=admin
=disabled=no
=password=test
=shared-users=1
=username=test
<<< /tool/user-manager/user/add
<<< =customer=admin
<<< =disabled=no
<<< =password=test
<<< =shared-users=1
<<< =username=test
<<<
>>> !done
>>> =ret=*1
>>>
<<< /tool/user-manager/user/create-and-activate-profile
<<< =numbers=*1
<<< =customer=admin
<<< =profile=a
<<<
>>> !done
>>>