Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Hilfe zu OTRS Problemen aller Art
Post Reply
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Hallo,

ich bin auf ein nettes Script gestoßen, um Kundenbenutzer automatisch OTRS-Gruppen mittels AD-Gruppen mapping zuzuweisen.
Nun habe ich jedoch das Problem, dass im betreuten Active Directory bei jeder wichtigen Sicherheitsgruppe ein führendes # steht.
So gibt es zum Beispiel für die Gruppe IT mit dem DN "CN=\#IT,OU=Benutzer, ......" .
Weiter haben auch OU's auf oberster Ebene ein führendes # stehen.

In besagtem Script wird auf eine .ini verwiesen, in welcher die Gruppen hinterlegt werden sollen.
Das Script selbst benötigt auch Informationen aus dem AD, welche das #-Symbol beinhalten.

Ich habe bereits versucht das # mit Backslash, einfachen Anführungszeichen und doppelten Anführungszeichen zu excluden, jedoch ohne erfolg.

Wenn das Script für eine Teststruktur ohne # im gleichen AD konfiguriert wird klappt dies wunderbar.
Sobald ich auf die Live-Umgebung switche erhalte ich Fehler an den Stellen der #-Symbole.

Gibt es eine Möglichkeit die # als einfaches Zeichen zu setzen? Also die Kommentarfunktion zu umgehen? Kann vielleicht auf den ASCII Wert gezeigt werden, oder gibt es dann doch etwas praktikableres?

Viele Grüße und Danke im Voraus
1337
wurzel
Znuny guru
Posts: 3224
Joined: 08 Jul 2010, 22:25
Znuny Version: x.x.x
Real Name: Florian

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by wurzel »

Hi,

was hast Du für ein Skript? OTRS kann das out of the box, sollte auch mit # gehen (hab' ich aber nicht probiert)

viele Grüße
Flo
OTRS 8 SILVER (Prod)
OTRS 8 auf Debian 11 (Test)
Znuny 7.x latest version testing auf Debian 11

-- Ich beantworte keine Forums-Fragen PN - No PN please

I won't answer to unfriendly users any more. A greeting and regards are just polite.
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Das ist mein Script:

Code: Select all

#!/usr/bin/perl
# --
# bin/iks.AddLDAPCustomer2Group.pl - Sync LDAP users belonging to specific LDAP groups to OTRS customer users on specific OTRS groups
# version: 1.2
#
# USAGE bin/iks.AddLDAPCustomer2Group.pl --map <LDAP2OTRS.ini> [--simulate]
#
# <LDAP2OTRS.ini> is a text file with the following format: LDAP-Group|OTRS-Group|Permission
#
# it is possible to assign many OTRS groups to the same LDAP group
# LDAP groups must be specified with the Distinguished Name (DN) notation (see RFC-Specification RFC 4514)
# Permissions can be either ro or rw
# - For all users in $$LDAP_BASE_OTRS_CUSTOMERS_USERS LDAP group that are OTRS Customer users the permissions for OTRS groups specified within LDAP2OTRS.ini file will be revoked
# - For all users in LDAP groups specified within LDAP2OTRS.ini file that are also OTRS Customer users the permissions for OTRS groups specified within LDAP2OTRS.ini file will be applied
# - The permissions related to any other LDAP and OTRS group NOT specified within LDAP2OTRS.ini file will be left untouched
# - The permissions related to any OTRS user directly specified on the OTRS db, will be left untouched
#
# if the --simulate parameter is specified, no actual operation is performed on OTRS
#
# Copyright (C) 2015 IKS srl, http://www.iks.it/
# --
use strict;
use warnings;

use Getopt::Long qw(GetOptions);
Getopt::Long::Configure qw(gnu_getopt);

use Sys::Hostname;
use Time::Local;
use Net::LDAP;
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::System::ObjectManager;

# create object manager
local $Kernel::OM = Kernel::System::ObjectManager->new(
    'Kernel::System::Log' => {
        LogPrefix => 'OTRS-iks.AddLDAPCustomer2Group',
    },
);

# init logging parameters
# Generic log call prototype is:
# $LogMsg="...string to log...";
# &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
my $LogFileName='/otrs_bck/groupsAD/LDAP2OTRS';   # >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO YOUR NEEDS
my $LogMsg;
my $EchoToDisplay=\1;

my $simulate;
my $filename;
GetOptions(
   'simulate|s' => \$simulate, # simulation mode, no actual operation will be performed on OTRS
   'map|m=s' => \$filename, # input file, each line has the format: ldapGrp,otrsGrp,permission
   ) or die "USAGE: $0 --map <LDAP2OTRS.ini> [--simulate]\n";

if (!defined($filename)) {
        print STDERR "USAGE: $0 --map <LDAP2OTRS.ini> [--simulate]\n";
        exit;
}

$LogMsg="************************** STARTING AddLDAPCustomer2Group PROCEDURE **************************";
&LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);

# create common objects
my %LDAP2OTRS; # hashtable of hashtables $LDAP2OTRS{ldapGrp}{otrsGrp}=rw|ro

# CONSTANTS
# LDAP Server
my $LDAP_SERVER = \"dc01.firma.tld";   # >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO THE SETTINGS IN /opt/otrs/Kernel/Config.pm (Customer::AuthModule::LDAP::Host)

# LDAP Base Domain
my $LDAP_BASE_DOMAIN=\"dc=firma,dc=tld";   # >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO THE SETTINGS IN /opt/otrs/Kernel/Config.pm (Customer::AuthModule::LDAP::BaseDN)

# technical user to browse LDAP
my $UID = \"OTRS@firma.tld";   # >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO THE SETTINGS IN /opt/otrs/Kernel/Config.pm (Customer::AuthModule::LDAP::SearchUserDN)
my $BIND_PWD = \"passwort";   # >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO THE SETTINGS IN /opt/otrs/Kernel/Config.pm (Customer::AuthModule::LDAP::SearchUserPw)

my $LDAP_BASE_OTRS_CUSTOMERS_USERS=\"CN=\#IT,OU=Benutzer,OU=Abteilung,OU=Abteilungen,OU=\#Standort,DC=Firma,DC=tld";   ## >>>> JUST AN EXAMPLE... EDIT THIS LINE ACCORDING TO THE SETTINGS IN /opt/otrs/Kernel/Config.pm (Customer::AuthModule::LDAP::GroupDN)

# connect to LDAP server
my $ldap = Net::LDAP -> new ($$LDAP_SERVER) || die "ERROR: Could not connect to LDAP server\n";

# bind to LDAP server
$ldap -> bind($$UID, password => $$BIND_PWD);

# list attributes to be queried
my @Attrs = ('memberOf','sAMAccountName','userAccountControl');

# open $filename for read (if it exists)
my $fh;
if ( -e $filename ) {
   open $fh, '<', $filename or die "ERROR: Cannot open $filename: $!";
}
else {
   $LogMsg="ERROR: $filename does not exist!";
   &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#   print STDERR "ERROR: $filename does not exist!\n";
   exit;
}

# composition of %LDAP2OTRS hashtable
while ( my $line = <$fh> ) {
   chomp $line;
   $line =~ s/\#.*//;  # skipping comment lines
   $line =~ s/\#$//;   # skipping each # character at end of line
   $line =~ s/^\s+//;  # skipping starting blank
   $line =~ s/\s+$//;  # skipping ending blank
   next unless length $line; # if something useful is left...
   my @row = split( /\|/, $line );
   $LDAP2OTRS{$row[0]}{$row[1]}=$row[2];
}

# close $filename
close($fh);

# DEBUG START
# read %LDAP2OTRS hashtable
#for my $ldapGrp ( keys %LDAP2OTRS ) {
#   print "$ldapGrp: \n";
#   for my $otrsGrp ( keys %{ $LDAP2OTRS{$ldapGrp} } ) {
#      print "$otrsGrp=$LDAP2OTRS{$ldapGrp}{$otrsGrp} ";
#   }
#   print "\n";
#}
# DEBUG END

# REVOKING PERMISSIONS TO ALL USERS BELONGING TO $$LDAP_BASE_OTRS_CUSTOMERS_USERS
for my $ldapGrp ( keys %LDAP2OTRS ) {
   for my $otrsGrp ( keys %{ $LDAP2OTRS{$ldapGrp} } ) {
      # check if $otrsGrp is an OTRS group
      my $CheckGroupID = $Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupLookup(
         Group => $otrsGrp,
      );
      if ( !$CheckGroupID ) {
         $LogMsg="ERROR: Failed to get Group ID: '$otrsGrp' is NOT an OTRS group.";
         &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#         print STDERR "ERROR: Failed to get Group ID: '$otrsGrp' is NOT an OTRS group.\n";
         next;
      }
      
      # search for users in $$LDAP_BASE_OTRS_CUSTOMERS_USERS
      # see https://technet.microsoft.com/it-it/library/aa996205%28v=exchg.65%29.aspx for details      
      my $result = &LDAPsearch ( $ldap, "(&(objectCategory=user)(memberOf=$$LDAP_BASE_OTRS_CUSTOMERS_USERS)(|(userAccountControl=512)(userAccountControl=544)(userAccountControl=66048)(userAccountControl=66080)))", \@Attrs, "$$LDAP_BASE_DOMAIN" );
      
      # Use the following table as a reference for userAccountControl values
      # 512........Enabled Account
      # 514........Disabled Account
      # 544........Enabled, Password Not Required
      # 546........Disabled, Password Not Required
      # 66048......Enabled, Password Doesn't Expire
      # 66050......Disabled, Password Doesn't Expire
      # 66080......Enabled, Password Doesn't Expire & Not Required
      # 66082......Disabled, Password Doesn't Expire & Not Required
      # 262656.....Enabled, Smartcard Required
      # 262658.....Disabled, Smartcard Required
      # 262688.....Enabled, Smartcard Required, Password Not Required
      # 262690.....Disabled, Smartcard Required, Password Not Required
      # 328192.....Enabled, Smartcard Required, Password Doesn't Expire
      # 328194.....Disabled, Smartcard Required, Password Doesn't Expire
      # 328224.....Enabled, Smartcard Required, Password Doesn't Expire & Not Required
      # 328226.....Disabled, Smartcard Required, Password Doesn't Expire & Not Required
      
      my @entries = $result->entries;
      if (scalar(@entries) >0) {
         foreach my $entr ( @entries ) {
            my $thisUser = $entr->get_value('sAMAccountName');
            # check if $thisUser is an OTRS customer
            my $CheckCustomerName = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerName(
               UserLogin => $thisUser,
            );
            if ( !$CheckCustomerName ) {
               $LogMsg="ERROR: Failed to get Customer data: '$thisUser' is NOT an OTRS customer user.";
               &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#               print STDERR "ERROR: Failed to get Customer data: '$thisUser' is NOT an OTRS customer user.\n";
               next;
            }      

            $LogMsg="REVOKING ALL PERMISSIONS TO $thisUser on $otrsGrp ...";
            &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#            print "REVOKING ALL PERMISSIONS TO $thisUser on $otrsGrp ...\n";
            unless ($simulate) {
               # revoking all permissions...
               if ( !$Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberAdd(Group => $otrsGrp, GID => $CheckGroupID, UID => $thisUser, Permission => { rw => 0, }, UserID => 1, ValidID => 1) ) {
                  $LogMsg="ERROR: Can't reset rw permission for $thisUser Customer on $otrsGrp group";
                  &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#                  print STDERR "ERROR: Can't reset rw permission for $thisUser Customer on $otrsGrp group\n";
               }
               if ( !$Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberAdd(Group => $otrsGrp, GID => $CheckGroupID, UID => $thisUser, Permission => { ro => 0, }, UserID => 1, ValidID => 1) ) {
                  $LogMsg="ERROR: Can't reset ro permission for $thisUser Customer on $otrsGrp group";
                  &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#                  print STDERR "ERROR: Can't reset ro permission for $thisUser Customer on $otrsGrp group\n";
               }
            }
         }
      }
   }
}

# ASSIGNING PERMISSIONS
for my $ldapGrp ( keys %LDAP2OTRS ) {
   $LogMsg="Searching users within $ldapGrp ...";
   &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#   print "Searching users within $ldapGrp ...\n";

   # search for users in $ldapGrp
   my $result = &LDAPsearch ( $ldap, "(&(objectCategory=user)(memberOf=$ldapGrp)(|(userAccountControl=512)(userAccountControl=544)(userAccountControl=66048)(userAccountControl=66080)))", \@Attrs, "$$LDAP_BASE_DOMAIN" );
   # get entries from result object
   my @entries = $result->entries;
   if (scalar(@entries) >0) {
      foreach my $entr ( @entries ) {
         my $thisUser = $entr->get_value('sAMAccountName');
         for my $otrsGrp ( keys %{ $LDAP2OTRS{$ldapGrp} } ) {
            my $thisPermission = lc $LDAP2OTRS{$ldapGrp}{$otrsGrp};
            # check if $thisPermission is correct
            if ($thisPermission !~ /^r[ow]|reset$/) {
               $LogMsg="ERROR: Wrong permission: '$thisPermission' is NOT a standard permission.";
               &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#               print STDERR "ERROR: Wrong permission: '$thisPermission' is NOT a standard permission.\n";
               next;
            }
            if ($thisPermission eq 'reset') {
               # permissions for this OTRS group have been already reset... just skipping to next group.
               next;
            }
            
            # check if $otrsGrp is an OTRS group
            my $CheckGroupID = $Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupLookup(
               Group => $otrsGrp,
            );
            if ( !$CheckGroupID ) {
               $LogMsg="ERROR: Failed to get Group ID: '$otrsGrp' is NOT an OTRS group.";
               &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#               print STDERR "ERROR: Failed to get Group ID: '$otrsGrp' is NOT an OTRS group.\n";
               next;
            }
            # check if $thisUser is an OTRS customer
            my $CheckCustomerName = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerName(
               UserLogin => $thisUser,
            );
            if ( !$CheckCustomerName ) {
               $LogMsg="ERROR: Failed to get Customer data: '$thisUser' is NOT an OTRS customer user.";
               &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#               print STDERR "ERROR: Failed to get Customer data: '$thisUser' is NOT an OTRS customer user.\n";
               next;
            }
            $LogMsg="ASSIGNING $thisPermission PERMISSIONS TO $thisUser on $otrsGrp ...";
            &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#            print "ASSIGNING $thisPermission PERMISSIONS TO $thisUser on $otrsGrp ...\n";
            unless ($simulate) {
               if ($thisPermission eq 'ro') {
                  # revoking all permissions, beforehand (otherwise if $thisUser has already rw permissions on $otrsGrp, ro permission cannot be simply applied)
                  if ( !$Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberAdd(Group => $otrsGrp, GID => $CheckGroupID, UID => $thisUser, Permission => { rw => 0, }, UserID => 1, ValidID => 1) ) {
                     $LogMsg="ERROR: Can't reset rw permission for $thisUser Customer on $otrsGrp group";
                     &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#                     print STDERR "ERROR: Can't reset rw permission for $thisUser Customer on $otrsGrp group\n";
                  }
                  if ( !$Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberAdd(Group => $otrsGrp, GID => $CheckGroupID, UID => $thisUser, Permission => { ro => 0, }, UserID => 1, ValidID => 1) ) {
                     $LogMsg="ERROR: Can't reset ro permission for $thisUser Customer on $otrsGrp group";
                     &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#                     print STDERR "ERROR: Can't reset ro permission for $thisUser Customer on $otrsGrp group\n";
                  }
               }
               # ...then setting $thisPermission
               if ( !$Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberAdd(Group => $otrsGrp, GID => $CheckGroupID, UID => $thisUser, Permission => { $thisPermission => 1, }, UserID => 1, ValidID => 1) ) {
                  $LogMsg="ERROR: Can't set $thisPermission permission for $thisUser Customer on $otrsGrp group";
                  &LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);
#                  print STDERR "ERROR: Can't set $thisPermission permission for $thisUser Customer on $otrsGrp group\n";
               }
            }
         }
      }
   }
}

# unbind (disconnect) from server
$ldap->unbind;

$LogMsg="************************** AddLDAPCustomer2Group PROCEDURE COMPLETE! **************************";
&LogToFile($LogFileName, $LogMsg, $$EchoToDisplay);

sub LDAPsearch
{
   my ($ldap,$searchString,$attrs,$base) = @_;
   # if they don't pass a base... set it for them
   if (!$base ) { $base = "$$LDAP_BASE_DOMAIN"; }
   # if they don't pass an array of attributes...
   # set up something for them

#   if (!$attrs ) { $attrs = [ 'cn','type' ]; }
   if (!$attrs ) { $attrs = [ 'sAMAccountName' ]; }

   my $result = $ldap->search ( base    => "$base",
                         scope   => "sub",
                         filter  => "$searchString",
                         attrs   =>  $attrs
                        );
   return $result;
}

sub LogToFile
{
   my ($inLogFileName, $inLogMessage, $echoToDisplay) = @_;
   
   my $OPENFILE_ERROR=\106;
   
   if ($simulate)
   {
      $inLogMessage='SIMULATION :: '.$inLogMessage;
   }
   
   if ($inLogFileName eq "")
   {
      if ($echoToDisplay == 1)
      {
         print "$inLogMessage\n";
      }
      return;
   }

   my $LogFileName00=$inLogFileName.'_00.log';
   my $LogFileName01=$inLogFileName.'_01.log';
   
   my @ExactlyNow=localtime;
   # @ExactlyNow = ( seconds , minutes , hours , day_of_month , month-1 , year-1900 , day_of_week , day_of_year , isday )

   if ($ExactlyNow[3] < 10)
   {$ExactlyNow[3]="0".$ExactlyNow[3];} # set 2 digits precision for day
   if ($ExactlyNow[2] < 10)
   {$ExactlyNow[2]="0".$ExactlyNow[2];} # set 2 digits precision for hours
   if ($ExactlyNow[1] < 10)
   {$ExactlyNow[1]="0".$ExactlyNow[1];} # set 2 digits precision for minutes
   if ($ExactlyNow[0] < 10)
   {$ExactlyNow[0]="0".$ExactlyNow[0];} # set 2 digits precision for seconds
   $ExactlyNow[5]=$ExactlyNow[5]+1900;
   my @Months=('jan','feb','mar','apr','maj','jun','jul','aug','sep','oct','nov','dec');
   for my $cnt (0..11)
   {
      if ($ExactlyNow[4] eq $cnt)
      { $ExactlyNow[4] = $Months[$cnt]; }
   }

   my $TimeStamp=$ExactlyNow[5].'-'.$ExactlyNow[4].'-'.$ExactlyNow[3].' '.$ExactlyNow[2].':'.$ExactlyNow[1].':'.$ExactlyNow[0];

   my @attrs = stat($LogFileName00);
   
   if (defined($attrs[7])) # if $LogFileName00 exists...
   {
      $attrs[7]=$attrs[7]/1024;
      # check the size of $LogFileName00
      if ($attrs[7] > 2000) # if > 2MB
      {
         rename ($LogFileName00, $LogFileName01);
         if (!open (WLOG,"> $LogFileName00")) # open $LogFileName00 for write
         {
            print STDERR "SYSTEM ERROR: The Logfile $LogFileName00 cannot be created!\n";
            return $$OPENFILE_ERROR;
         }
      }
      else # the size of $LogFileName00 is less than 2MB
      {
         if (!open (WLOG,">> $LogFileName00"))
         {
            print STDERR "SYSTEM ERROR: The Logfile $LogFileName00 cannot be created!\n";
            return $$OPENFILE_ERROR;
         }
      }
   }
   else # $LogFileName00 does not exists
   {
      if (!open (WLOG,"> $LogFileName00"))
      {
         print STDERR "SYSTEM ERROR: The Logfile $LogFileName00 cannot be created!\n";
         return $$OPENFILE_ERROR;
      }
   }
   
   print WLOG "$TimeStamp :: $inLogMessage\n";
   close (WLOG);
   
   if ($echoToDisplay == 1)
   {
      print "$inLogMessage\n";
   }
}
und es liest folgende Datei aus:

Code: Select all

CN=\#IT,OU=Benutzer,OU=Abteilung,OU=Abteilungen,OU=\#Standort,DC=Firma,DC=tld|Aussendienst|rw
hier steht die AD Gruppe|hier steht die OTRS Gruppe|ro/rw
Wenn ich eine Teststruktur im gleichen Betrieb aufsetze und die "#" entferne funktioniert es einwandfrei.
In der jetzigen Umgebung meckert das Script jedoch folgenden Fehler an:

Code: Select all

root@Ticketsystem:~# /opt/otrs/bin/otrs.AddLDAPCustomer2Group.pl --map /tmp/LDAP2OTRS.ini
************************** STARTING AddLDAPCustomer2Group PROCEDURE **************************
[Thu Jul 13 16:22:46 2017] otrs.AddLDAPCustomer2Group.pl: Use of uninitialized value $row[1] in hash element at /opt/otrs/bin/otrs.AddLDAPCustomer2Group.pl line 116, <$fh> line 1.
[Thu Jul 13 16:22:46 2017] otrs.AddLDAPCustomer2Group.pl: Use of uninitialized value $row[1] in hash element at /opt/otrs/bin/otrs.AddLDAPCustomer2Group.pl line 116, <$fh> line 2.
ERROR: OTRS-iks.AddLDAPCustomer2Group-26 Perl: 5.20.2 OS: linux Time: Thu Jul 13 16:22:46 2017

 Message: Got no Group or GroupID!

 Traceback (2029):
   Module: Kernel::System::CustomerGroup::GroupLookup Line: 349
   Module: /opt/otrs/bin/otrs.AddLDAPCustomer2Group.pl Line: 137

ERROR: Failed to get Group ID: '' is NOT an OTRS group.
ERROR: OTRS-iks.AddLDAPCustomer2Group-26 Perl: 5.20.2 OS: linux Time: Thu Jul 13 16:22:46 2017

 Message: Got no Group or GroupID!

 Traceback (2029):
   Module: Kernel::System::CustomerGroup::GroupLookup Line: 349
   Module: /opt/otrs/bin/otrs.AddLDAPCustomer2Group.pl Line: 137

ERROR: Failed to get Group ID: '' is NOT an OTRS group.
Searching users within CN=\ ...
Searching users within CN={("'\\\ ... <<<<< [i]hier htte ich " und ' und \ in verschiedenster Form getestet ohne Erfolg[/i]
************************** AddLDAPCustomer2Group PROCEDURE COMPLETE! **************************
Ich werde gleich nochmal durchtesten, ob der Fehler nur aus der ausgelesenen Datei, oder aus Script und Datei kommt.
Last edited by BeatYa on 14 Jul 2017, 09:18, edited 1 time in total.
1337
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

das script brauchst Du eigentlich nicht. OTRS kann LDAP Gruppen zu OTRS Gruppen (nicht empfohlen) oer Rollen beim Login direkt matchen.

Siehe Defaults.pm
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Die Funktion nutze ich bereits.
Jedoch geht es dabei soweit ich es verstanden habe um die Zuweisung von AD-Gruppen zu Agenten-Gruppen.
Wir haben jedoch nur 5 Agenten auf 350 Kunden im Einsatz.

Daher finde ich die automatische Agentengruppenzuweisung zwar nett, aber ich benötige die automatische Kundenbenutzer-Gruppen-zuweisung.
Damit soll dafür gesorgt werden, dass jeder Kundenbenutzer auf die Queue seiner Abteilung zugreifen kann und die Gruppenzuweisung nicht manuell im OTRS vorgenommen werden muss.
1337
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

Gut, da Kunden Gruppen Zuordnung nur bei einigen wenigen komplexen Szenarien sinnvoll sind ein paar Anmerkungen:

- Kundenbezogene Queues (in dem Fall Abteilungen) machen kein SInn
- was möchtest Du erreichen durch die Kunden - Gruppen Zuordnung? Nur das das Dropdown beim Erstellen des Tickets durch den Kunden eingeschränkt wird? (Hier wären ggf. ACLs sinnvoll)
- # Marks als Gruppen Name ist eine genauso blöde Idee wie $ \ oder andere Sonderzeichen
- Perl Kenntnisse helfen wenn man mit Skripten die man im Internet findet hantiert (es handelt sich hier nicht um ein offizielles OTRS Skript (Schau Dir mal den Block unter "composition of %LDAP2OTRS hashtable" genauer an
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

jojo wrote:Gut, da Kunden Gruppen Zuordnung nur bei einigen wenigen komplexen Szenarien sinnvoll sind ein paar Anmerkungen:

- Kundenbezogene Queues (in dem Fall Abteilungen) machen kein SInn
- was möchtest Du erreichen durch die Kunden - Gruppen Zuordnung? Nur das das Dropdown beim Erstellen des Tickets durch den Kunden eingeschränkt wird? (Hier wären ggf. ACLs sinnvoll)
- # Marks als Gruppen Name ist eine genauso blöde Idee wie $ \ oder andere Sonderzeichen
- Perl Kenntnisse helfen wenn man mit Skripten die man im Internet findet hantiert (es handelt sich hier nicht um ein offizielles OTRS Skript (Schau Dir mal den Block unter "composition of %LDAP2OTRS hashtable" genauer an

Es schien mir so, als gäbe es die Möglichkeit über eine Kundengruppen-Zuweisung die im /Customer.pl angezeigten Tickets zu filtern.
Mein Vorhaben war es einer Abteilung ro-Rechte auf den gesamten Ticketbereich der Abteilung zu geben.
Ein Einkauf hat in den Tickets der Technik nichts zu suchen und umgekehrt.

Dass # Marks keine gute Idee für die Namensgebung im AD sind ist mir durchaus bewusst, jedoch wurde es nicht von mir aufgesetzt und die Beteiligten sträuben sich gegen eine Umbenennung, da sie sideeffects fürchten....

Perl Kenntnisse hätte ich dafür weniger gebraucht als wohl etwas mehr Aufmerksamkeit beim Script aufarbeiten. Den Part hätte ich selbst sehen müssen.
Danke für die Hilfe! Nachdem der Part auskommentiert wurde läuft es.

Ich hoffe mal, dass ich mit meiner Einschätzung der Rechtevergabe über Kundenbenutzer-Gruppen nicht auf dem Holzweg bin.

Nochmals danke fürs durcharbeiten und die Hilfe beim Anwenden des Scripts!



-> das Script ist nicht irgendwo aus dem Netz sondern hier aus dem Forum.
Link: viewtopic.php?f=60&t=28667
Dass es dennoch kein offizielles Script ist weiß ich wohl.
Es wird daher erst auf einem Test-OTRS, was am gleichen AD hängt ausgerollt und getestet.
Last edited by BeatYa on 14 Jul 2017, 10:37, edited 1 time in total.
1337
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

BeatYa wrote: Es schien mir so, als gäbe es die Möglichkeit über eine Kundengruppen-Zuweisung die im /Customer.pl angezeigten Tickets zu filtern.
Mein Vorhaben war es einer Abteilung ro-Rechte auf den gesamten Ticketbereich der Abteilung zu geben.
Ein Einkauf hat in den Tickets der Technik nichts zu suchen und umgekehrt.

EIn Kundenbenutzer kann immer nur die Tickets lesen, die entweder von ihm eröffnet wurden, oder die gleiche CustomerID haben (oder eine der CustomerIDs die in einem speraten Feld der Kundendaten vorgehalten werden). Die Queue spielt hierbei keine Rolle.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

BeatYa wrote:[

-> das Script ist nicht irgendwo aus dem Netz sondern hier aus dem Forum.
Link: viewtopic.php?f=60&t=28667
AUch das ist "irgendwo" aus dem Netz :-D
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Kann es darüber wenigstens einer Queue zugeordnet werden?^^
Ansonsten machen Kundenbenutzer-Gruppen ja irgendwie wenig bis gar keinen Sinn?!

Wie wirken sich die Rechte ro / rw aus, wenn nicht auf Tickets?
1337
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

Du kannst damit das Dropdown bei der Ticketerstellung einschränken (zeigt nur die Queues mit rw auf die Gruppe). Das geht aber auch über eine ACL, z.B. über die CustomerID.

Die Anwendungsfälle für Customer Group Support sind berschaubar, Du wirst sie wohl nicht brauchen
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Ach Mist, mir schien es, als gäbe es Einsicht auf die Tickets der Gruppe...
Kann ein solcher Zugriff eingerichtet werden? Eventuell über Gruppen? Dann wäre es gar nicht mal ganz umsonst gewesen.
1337
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by jojo »

Warum gibst Du denn nicht einfach allen usern einer Gruppe die gleiche CustomerID?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
BeatYa
Znuny newbie
Posts: 18
Joined: 27 Jun 2017, 10:31
Znuny Version: OTRS 5S
Real Name: René
Company: Makita

Re: Wie exclude ich die Funktion vom Hash (#)-Symbol in perl

Post by BeatYa »

Ja wenn es damit funktioniert danke ich doch einmal erneut für den Tipp.

Gruß
René

-> Läuft jetzt sowohl über Gruppen, als auch über CustomerID.
Funktioniert einwandfrei. Freue mich sehr darüber :)
1337
Post Reply