AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 641650
Accepted
Michael
Michael
Asked: 2014-11-04 07:07:13 +0800 CST2014-11-04 07:07:13 +0800 CST 2014-11-04 07:07:13 +0800 CST

OTRS 中的大规模禁用客户

  • 772

问题在于OTRS客户。我不能使用外部客户后端,所以我想通过 CSV 文件更新客户数据库。我已经编写了一个脚本来通过otrs.AddCustomerUser.pl.

但是如何通过脚本批量禁用老客户?

php
  • 1 1 个回答
  • 639 Views

1 个回答

  • Voted
  1. Best Answer
    Federico Sierra
    2014-11-04T09:04:20+08:002014-11-04T09:04:20+08:00

    我创建了一个基于otrs.AddCustomerUser.pl 使客户用户无效的脚本:

    otrs.DisableCustomerUser.pl:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use File::Basename;
    use FindBin qw($RealBin);
    use lib dirname($RealBin);
    use lib dirname($RealBin) . '/Kernel/cpan-lib';
    use lib dirname($RealBin) . '/Custom';
    
    use Kernel::Config;
    use Kernel::System::Encode;
    use Kernel::System::Log;
    use Kernel::System::Time;
    use Kernel::System::Main;
    use Kernel::System::DB;
    use Kernel::System::CustomerUser;
    
    # create common objects
    my %CommonObject;
    $CommonObject{ConfigObject} = Kernel::Config->new(%CommonObject);
    $CommonObject{EncodeObject} = Kernel::System::Encode->new(%CommonObject);
    $CommonObject{LogObject}
        = Kernel::System::Log->new( %CommonObject, LogPrefix => 'OTRS-otrs.DisableCustomerUser.pl' );
    $CommonObject{TimeObject} = Kernel::System::Time->new(%CommonObject);
    $CommonObject{MainObject} = Kernel::System::Main->new(%CommonObject);
    $CommonObject{DBObject}   = Kernel::System::DB->new(%CommonObject);
    $CommonObject{UserObject} = Kernel::System::CustomerUser->new(%CommonObject);
    
    my %Options;
    use Getopt::Std;
    getopt( 'c', \%Options );
    unless ( $ARGV[0] ) {
        print
            "$FindBin::Script [-c CustomerID] username\n";
        print "\n";
        exit;
    }
    
    my %Param;
    
    $Param{Source} = 'CustomerUser';
    $Param{UserLogin} = defined $Options{c} ? $Options{c} : $ARGV[0];
    
    my %User = $CommonObject{UserObject}->CustomerUserDataGet( User => $Param{UserLogin});
    
    if ( !%User ) {
        print "No such user '$Param{UserLogin}'!\n";
        exit(1);
    }
    
    my $Success = $CommonObject{UserObject}->CustomerUserUpdate(
        Source => 'CustomerUser',
        ID              => $User{UserCustomerID},
        UserCustomerID  => $User{UserCustomerID},
        UserLogin       => $User{UserCustomerID},
        UserFirstname   => $User{UserFirstname},
        UserLastname    => $User{UserLastname},
        UserEmail       => $User{UserEmail},
        ValidID         => 2,
        UserID          => 1,
    );
    
    if($Success eq 1){
        print "Set customer user $User{UserCustomerID} to invalid.\n";
    }
    
    exit(0);
    

    调用:

    # otrs.DisableCustomerUser.pl [-c CustomerID] username
    
    • 1

相关问题

  • 用户特定的 Php.ini 当 php 作为模块运行时?

  • 使 php mail() 函数在 ubuntu-server 上工作的步骤是什么?

  • Web 服务器和数据库服务器位于完全不同的位置

  • PHP 作为 CGI 还是 Apache 模块?

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve