0

因此,我有以下功能可以使用 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 )
4

1 回答 1

0

快速回复

你不能传递属性 word user,你需要传递标识用户的数字。如文档所述,最好先创建然后创建并激活配置文件

解释

RouterOS APi命令词紧跟 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
>>> 


于 2021-02-24T22:44:31.730 回答