OTRS AD authentication based on username - otrs

I have configured otrs open source edition to authenticate based on email address of user on customer page.Is there is any way we can authenticate based on their username ?

Yes it is possible.
What is your authentication backend for the OTRS ( DB, LDAP, BASIC )
In case it is DB, then please add these lines in Kernel/Config.pm
$Self->{'Customer::AuthModule'} = 'Kernel::System::CustomerAuth::DB';
$Self->{'Customer::AuthModule::DB::Table'} = 'customer_user';
$Self->{'Customer::AuthModule::DB::CustomerKey'} = 'login';
It will set the required customerKey to login column o the table customer_user
UPDATE #1
Well, in this case edit your Config.pm file and add these lines:
Pay attention to variables LDAP::UID, CustomerKey and mapping for UserCustomerID. Review your AD and make sure, that EVERY customer, has unique value in sAMAccountName
$Self->{'Customer::AuthModule::LDAP::UID'} = 'sAMAccountName';
$Self->{CustomerUser} = {
Module => 'Kernel::System::CustomerUser::LDAP',
Params => {
Host => 'host.example.com',
BaseDN => 'OU=BaseOU,DC=example,DC=com',
SSCOPE => 'sub',
UserDN =>'otrs_ldap',
UserPw => 'PASSWORD',
},
# customer unique id
CustomerKey => 'sAMAccountName',
# customer #
CustomerID => 'mail',
CustomerUserListFields => ['sAMAccountName', 'cn', 'mail'],
CustomerUserSearchFields => ['sAMAccountName', 'cn', 'mail'],
CustomerUserSearchPrefix => '',
CustomerUserSearchSuffix => '*',
CustomerUserSearchListLimit => 250,
CustomerUserPostMasterSearchFields => ['mail'],
CustomerUserNameFields => ['givenname', 'sn'],
Map => [
# note: Login, Email and CustomerID needed!
# var, frontend, storage, shown, required, storage-type
#[ 'UserSalutation', 'Title', 'title', 1, 0, 'var' ],
[ 'UserFirstname', 'Firstname', 'givenname', 1, 1, 'var' ],
[ 'UserLastname', 'Lastname', 'sn', 1, 1, 'var' ],
[ 'UserLogin', 'Login', 'sAMAccountName', 1, 1, 'var' ],
[ 'UserEmail', 'Email', 'mail', 1, 1, 'var' ],
[ 'UserCustomerID', 'CustomerID', 'sAMAccountName', 0, 1, 'var' ],
[ 'UserPhone', 'Phone', 'telephonenumber', 1, 0, 'var' ],
#[ 'UserAddress', 'Address', 'postaladdress', 1, 0, 'var' ],
#[ 'UserComment', 'Comment', 'description', 1, 0, 'var' ],
],
};

Related

how to set message rules by temporary_file_upload in config livewire

config/livewire.php:
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' Default: 'default'
'rules' => ['image', 'max:12288'], // Example: ['file', 'mimes:png,jpg'] Default: ['required', 'file', 'max:12288'] (12MB)
'messages' => ['image' => 'asdasd'],
'directory' => null, // Example: 'tmp' Default 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs.
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload gets invalidated.
],
I want change message current in [temporary_file_upload]['rules'], how to change it?

Set values for default address fields in Drupal 8

I need to set values for default address fields(langcode, country_code, administrative_area, address_locality ect.) when I create a node. I used below code in the submitForm function of a Form class which is extends by Drupal\Core\Form\FormBase class. But it not works for me.
$venueNode = Node::create([
'type' => 'venue',
'title' => 'Venue',
'field_address' => [
'country_code' => 'US',
'address_line1' => '1098 Alta Ave',
'locality' => 'Mountain View',
'administrative_area' => 'US-CA',
'postal_code' => '94043',
],
]);
$venueNode->save();
I made a mistake here. There should be a 0 index for field_address. Therefore the code should be like below.
$venueNode = Node::create([
'type' => 'venue',
'title' => 'Venue',
'field_address' => [
0 => [
'country_code' => 'US',
'address_line1' => '1098 Alta Ave',
'locality' => 'Mountain View',
'administrative_area' => 'US-CA',
'postal_code' => '94043',
],
],
]);
$venueNode->save();

Sets a collection of query parameters for the query being constructed

I'm trying to build a query by using array of options, as you see this is my array options:
$sort = $this->getParam('sort', 'creation_date');
$order = $this->getParam('order', 'desc');
$options = [
'sort' => [$sort => $order],
'filters' => [
[
'field' => 'state',
'operator' => 'LIKE',
'bind_name' => 'state1',
'value' => 'read',
'type' => 'OR'
],
[
'field' => 'state',
'operator' => 'LIKE',
'bind_name' => 'state2',
'value' => 'green'
]
]
];
As result i have this query:
SELECT COUNT(*) FROM `mytabel` `mytabel` INNER JOIN state_type t ON t.id_state_type = `mytabel`.id_state_type WHERE (`mytabel`.`state` LIKE :state1) **AND** (`mytabel`.`state` LIKE :state2) ORDER BY `mytabel`.`creation_date` desc
Params
state1 %read%
state2 %green%
My question is how i can have OR instead of AND in my query (array options)? because as result i want to have both of them (state1 %read% ,state2 %green%).
Thank you,

Laravel 5.5 - Validation of a string inside an object that is inside an array

I have the request:
`array:2 [
"alt_tags" => "1"
"name_pattern" => array:2 [
0 => "{"label":"Main Title","value":"main_title"}"
1 => "{"label":"Store Name","value":"store_name"}"
]
]`
In the class Request, I tried to validate the lines inside the object in the following way:
`$labels = \implode(',', [
'Main Title',
'Store Name',
]);
$values = \implode(',', [
'main_title',
'store_name',
]);
return [
'alt_tags' => 'required|boolean',
'name_pattern' => 'required|array|min:0|max:2',
'name_pattern.*.label' => "sometimes|string|in:{$labels}",
'name_pattern.*.value' => "sometimes|string|in:{$values}",
];`
But since the string is inside the object, then there is no way to get through the file_name_pattern. *.label:
data_get(request()->all(), 'name_pattern.0') // "{"label":"Main Title","value":"main_title"}"
data_get(request()->all(),'name_pattern.0.label'); // return NULL

How to use doctrine in SlimPHP with DB2?

I am trying use Doctrine within Slim to connect to a DB2 db. I am getting no errors. But, my app is not connecting to the database. I am using (likely incorrectly) this package for the driver: alanseiden/doctrine-dbal-ibmi
Here is the pertinent bit from my DIC:
// Doctrine
$container['db'] = function ($c) {
$settings = $c->get('settings');
$config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
$settings['doctrine']['meta']['entity_path'],
$settings['doctrine']['meta']['auto_generate_proxies'],
$settings['doctrine']['meta']['proxy_dir'],
$settings['doctrine']['meta']['cache'],
false
);
return \Doctrine\ORM\EntityManager::create($settings['doctrine']['connection'], $config);
};
And, the referenced settings:
// doctrine settings
'doctrine' => [
'meta' => [
'entity_path' => [
'app/src/Entity'
],
'auto_generate_proxies' => true,
'proxy_dir' => __DIR__.'/../cache/proxies',
'cache' => null,
],
'connection' => [
'Description' => 'IBM i Access ODBC Driver 64-bit',
'driver' => '\DoctrineDbalIbmi\Driver\DB2Driver::class',
'System' => 'xx.xx.xx.xx',
'UserID' => '*****',
'Password' => '*****',
'Naming' => 0,
'DefaultLibraries' => 'QGPL',
'ConnectionType' => 0,
'CommitMode' => 2,
'ExtendedDynamic' => 1,
'DefaultPkgLibrary' => 'QGPL',
'DefaultPackage' => 'A/DEFAULT(IBM),2,0,1,0,512',
'AllowDataCompression' => 1,
'MaxFieldLength' => 32,
'BlockFetch' => 1,
'BlockSizeKB' => 128,
'ExtendedColInfo' => 0,
'LibraryView' => 'ENU',
'AllowUnsupportedChar' => 0,
'ForceTranslation' => 0,
'Trace' => 0
]
]
],
];
I appreciate any help or direction.