How does laravel-adldap2 determine a user match with local user table - laravel

Laravel 6. CentOS 7
I have an existing user table that was used with standard Laravel Auth.
I've converted to LDAP but if a user logs in, the system tries to create a new user rather than syncing the existing entry unless there is an objectguid. This fails of course because of duplicate constraints.
I have another app that I'm doing the same thing and it seems to be working as expected. I cant figure out what's different on the configurations outside of some column names are different so the sync config looks a little different.
How does ldap2 determine a match in the local table before creating a new one?
Thanks

Related

How to use spatie / laravel-multitenancy with single database?

I want to convert my existing app to multi-tenant and don't want to use multiple databases. just read that the given package is allowing that.
https://github.com/spatie/laravel-multitenancy
I have read the single database documentation here: https://spatie.be/docs/laravel-multitenancy/v2/installation/using-a-single-database
But what's next ??
Let's say right now users are storing into users' tables, and by using this package I want to store users tenant-specific.
I don't found the real example anywhere. so better if anyone already implemented Spatie Multi-tenant by using a single Database, please help me here.
Thanks in advance.
Although spatie/laravel-multitenancy supporting single databases, it doesn't come with query scopes (and seems like there are no plans to add them, as you can see here: https://github.com/spatie/laravel-multitenancy/issues/124), so you would need to create them manually.
So, you need to:
add the tenant_id to your tenant-specific tables
add an observer to save the tenant_id when creating a new register in the table
add a global query scope to always filter the data using the current tenant id
You can see something similar in this video: https://www.youtube.com/watch?v=nCiNqboYFVQ
The difference is that you will use the current tenant returned by spatie/laravel-multitenancy instead of the logged user id to get the tenant data.
If you want a package that already brings the query scopes ready to use, you may try Tenancy for Laravel: https://tenancyforlaravel.com/docs/v3/single-database-tenancy
Or, if your application has a very simple multi-tenancy strategy (for example, the tenant is the logged user or his team) you can just create some query scopes without the need to use packages, exactly as the video above teaches, as it is much more simple to identify the tenant by the user_id or team_id, even in terminal commands and queue jobs (but seems that is not your case, as you need the users to belongs to a tenant).
I hope it helps you to select the correct package and strategy for your project.

Oracle Apex: Is it possible to change the default schema at runtime?

We have an Apex application (version 20.1) and our users must be able to change the database schema at runtime via button click (preferably without logging in again).
Currently we are solving this by installing our application multiple times, once per schema.
We recently discovered the function apex_export.get_application. We intend to use this function to bring our frontend under version control (finally!). We would like to deploy our application directly from the exported files. Having a single application, we would not have to mess with the internal component ids from the exported files.
Is it possible to install the application once and change the default schema via Pl/SQL code? Thank you!
I don't think this can be done, but perhaps the following is a reasonable compromise
add all the schemas you need to support to the workspace schema list
Any SQL (and I do mean any) in your app would be prefixed with an application item, eg
Before: select * from my_table
After: select * from &my_schema..my_table
At login time (or when a user selects it) you modify the MY_SCHEMA application item
(I've not tried this...so test/tread carefully)

Free Switch with 10+ digit regex validation?

When we install Free-Switch... by default we will get 20 endpoints (1000.xml to 1019.xml).
If we want to create our own endpoints like +919885098850 or +16308045480. How can we do that?
Instead of creating static endpoints inside Free-Switch... how to create endpoints outside?
For ex: 1. We will create endpoints inside MySql database...
2. We will authenticate from SIP application 3. Then forward calls to Free -Switch 4. Free-Switch will forward call to destination endpoint.
Can some explain me how to achieve this scenario?
You can create as many extensions as you want. The extension number 1000 to 1019 are just example extensions.
what you need to do is just copy the 1000.xml and change the extension number from 1000 to 919885098850 and set a password for it.
reload the freeswitch : /etc/init.d/freeswitch restart
and then try to register your phone with
Username : 919885098850
password : password in your xml
Domain : your IP address
That's all, you can now register 10 digit or 11 digit or whatever length extensions.
Freeswitch authenticates the users or extensions on the basis of the directory users defined in the directory folder with names like 1000.xml or XXXXXXX.xml
If you want to dynamically create and auth this extensions , you got 2 ways.
Either you write a service which will read data from your database and create one XML file in this folder
Another and personally my preferred way is using xml_curl module.
Trust me XML_CURL is best thing, I invested many hours in RnD just like your question and then in hard way I learned about xml_curl and it saved my day.

Laravel Multi Domain Session

I am not a superb developer, so I guess the problem I did run into is just to big for me.
I have a project where I have different subdomains for the current language. When I login a user it is logged only for the current subdomain. So when I login at "en.Aproject.com", and then go to "de.Aproject.com", the user will not be logged in. They don't share the session. I already tried to modify the 'domain' => null, in app/sessions.php. But when I change the value here the Login doesn't work at all. Then everytime a new Session-row is created in the DB and Laravel seems not to recognize them.
Is the current domain saved somehow in the session identifier? Is it possible to use one session for different domains? I found some stuff about OAuth and Single sign-on but I can not handle it by myself.
I was thinking about (when logging in and the credentials are correct) calling a script via Ajax, which should log in the user for all needed domains. But I would have to do the same for logging out.. And I will probably have a lot of domains. The project will have one base page and several subprojects (all with the different languages). Like this
mainproject.com
en.mainproject.com
de.mainproject.com
...
Aproject.com
en.Aproject.com
de.Aproject.com
...
Bproject.com
en.Bproject.com
de.Bproject.com
...
So it would just feel wrong to log in the user to like 20 different pages and create 20 sessions... It would feel better to just use one session for all of them.
Okay, I hope you understand the problem and someone already had the same problem and found a solution. Thanks!!!!!!!! greets. gerti
Background info.. I am using Laravel 4.2
Now I just tried something, maybe it helps someone. Actually point 2 is weird to me (see below)
I display these 3 things:
Session::getId()
Auth::getName()
var_dump(Session::all())
I display them on "de.Aproject.com". Here I am logged in.
And i display them on "en.Aproject.com"... Where I am still logged out (which I want to fix :D )
The value of Session::getId() is different on both sides. Thats the problem I guess, they should share the same.
The value of Auth::getName() is the same on both sides (login_82e5d2c56bdd0811318f0cf078b78bfc). Which I don't understand. Why does the second page have this value when i am not logged in?
The value of Session::all() is ["login_82e5d2c56bdd0811318f0cf078b78bfc"] => string(17) "test#test.de" on the first site, on the second its empty. Thats correct.
Since the default Laravel authentication system uses cookies to manage the session, you actually need to login the user on each subdomain you're going to use. To avoid that, you can use another session driver like database.

Database migrations in Grails

Suppose I have a database containing 3 tables in a grails application:
User
Activity
Friend
User table table has one to many relation to Activity and Friend tables so in User table I have:
static hasMany = [activies: Activity, friends: Friend]
and in Friend and Activity I have:
static belongsTo User.
Application is deployed and lets says thousands of customers have registered. Now changes are made in the database: Table Activity is dropped. A table Journal is created which is on the many sides of the User table. The User table has a new column added and this column cannot be null. An old column in Friend table is deleted that was also defined as not null.
So given above scenario and assume using MySQL what needs to be done to make above changes without deleting existing customers data and safely add the new table to existing customers?
Ruby on Rails comes with ActiveRecord for database migrations. Does Grails comes with something like this out of the box?
Currently in development when I run my grails application after adding a new not null column to a table, I get column cannot be null exception thrown unless I delete that table in the database before running grails application which would recreate the table if not exists. Obviously once the application is deployed I will not have the luxury to delete the table.
Unfortunately, the current version of Grails doesn't come with database migration. However, there is a plugin for Liquibase which makes migrations possible.
The next version of Grails (1.4, planned for Q1 2011) will supposedly contain a built-in migration tool, which I am very much looking forward to.
Note: I haven't used the Liquibase plugin, so I don't have any firsthand experience with it. I have seen numerous blog posts describing its use, however, and I'm probably going to use it in my next Grails project if 1.4 isn't out by then.

Resources