【问题标题】:Mikrotik Profile Activation Failing With No Such Command Error in PHPMikrotik 配置文件激活失败,PHP 中没有此类命令错误
【发布时间】:2021-02-26 05:26:57
【问题描述】:

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

【问题讨论】:

    标签: php mikrotik router-os


    【解决方案1】:

    快速回复

    你不能传递属性字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
    >>> 
    
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 2019-05-03
      • 1970-01-01
      • 2021-09-26
      • 2022-10-25
      • 2022-01-26
      相关资源
      最近更新 更多