philbertphotos / osticket-multildap-auth-plugin

Plugin for OS Ticket that allows for authentication with multiple domains.
GNU General Public License v3.0
28 stars 17 forks source link

PHP Fatal error: Non-static method cannot be called statically #51

Closed dylanglass6300 closed 2 years ago

dylanglass6300 commented 2 years ago

osTicket - v1.16.2 PHP - 8.0.18 Apache - 2.4.53

I've added the plugin, and it shows in my list of currently installed plugins. When I click on the name to configure it, the options area is empty, pictured below:

image

In my apache error log, the error I am getting is:

[Thu May 05 14:15:06.025931 2022] [php:error] [pid 772:tid 1872] [client ::1:55923] PHP Fatal error: Uncaught Error: Non-static method LdapMultiAuthPlugin::DateFromTimezone() cannot be called statically in C:\xampp\htdocs\osticket\include\plugins\multi-ldap\config.php:28\nStack trace:\n#0 C:\xampp\htdocs\osticket\include\plugins\multi-ldap\config.php(278): LdapMultiAuthPluginConfig->getschedule()\n#1 C:\xampp\htdocs\osticket\include\class.plugin.php(12): LdapMultiAuthPluginConfig->getOptions()\n#2 C:\xampp\htdocs\osticket\include\class.plugin.php(485): PluginConfig->__construct('9')\n#3 C:\xampp\htdocs\osticket\include\staff\plugin.inc.php(5): Plugin->getConfig()\n#4 C:\xampp\htdocs\osticket\scp\plugins.php(66): require('C:\\xampp\\htdocs...')\n#5 {main}\n thrown in C:\xampp\htdocs\osticket\include\plugins\multi-ldap\config.php on line 28, referer: http://localhost/osticket/scp/plugins.php

philbertphotos commented 2 years ago

I have not tested in PHP 8.0 I would have to make changes for it to work in that version.

philbertphotos commented 2 years ago

For now if you comment out line 278 and 279 should correct the issue for now till I create a fix. 'sync_schedule_show' => new SectionBreakField(array( //'label' => $('Next schedule: ' . $this->getschedule()) , //'hint' => $('Last run: ' . $this->getlastschedule()) , )) ,

dylanglass6300 commented 2 years ago

This worked to allow me to configure the plugin but I ran into more issues afterwards. I went ahead and downgraded and that allowed me to get through configuration and save without errors. However, now I get a different issue. It has not yet synced for the first time and says

"Next schedule: December 31 1969 7:00 pm Last run: December 31 1969 7:00 pm"

philbertphotos commented 2 years ago

@dylanglass6300 let me look at somethings and do it from scratch to see what is wrong. You will not need to comment out the functions if you downgraded PHP.

philbertphotos commented 2 years ago

@dylanglass6300 have you tried this? I remember adding it to correct this issue. image

dylanglass6300 commented 2 years ago

No luck. Tried reinstalling and reconfiguring as well to no avail. Still shows December 31 1969.

catalinchertes commented 2 years ago

I'm running into the same issues with php 8.0, will you make it compatible or is it a big headache? Thank you.

philbertphotos commented 2 years ago

@catalinchertes and @dylanglass6300 actively working on this should be done by Friday.

SamehElsakka commented 2 years ago

I have the same issue it shows Next schedule: January 01 1970 3:00 am and the reset/update schedule is ticked ,also the sync users button not working, i am using php7.4 and osticket version 1.15.2

PaysenPetersen commented 2 years ago

I would also be very happy about a revised version because I have the same problems. If I get the lines mentioned above, I get the page displayed. When spokes, I get an HTTP 500 error and the data is not saved.

philbertphotos commented 2 years ago

Yea I am working on this and should have it fixed by today ... hopefully.

I think this bug is because when I make changes I almost never install the plugin from scratch and it not creating the proper SQL tables to work properly

philbertphotos commented 2 years ago

Found the problem it was a missing database key ... this is a bug fix. I will update it a few more times after doing a few more tests but this works after removing it and reinstalling the plugin several times.

PaysenPetersen commented 2 years ago

I uninstalled the old version and installed the new version. Now you can save the data again and there are no more error messages. But the Sync button has no function for me and the LDAP users are also not syncralized. Does an additional library have to be installed? Or are special rights for a directory or database table?

I am currently users Ubuntu 20.04 and PHP 8. The Osticket LDAP authentication works.

I have a total of 3 ad domains Windows 2012 R2. Can you please see why the Sync doesn't work? In some screening, I always see an assignment table that is not shown for me.

philbertphotos commented 2 years ago

That part works but only if you use cron jobs … thats the only time the sync activates … i should put that in the readme. 3 AD domains is nice .. i tested up to 4 but actively use two.

catalinchertes commented 2 years ago

Hey there, updated the version, still getting the same errors, If I don't comment out the schedule lines I get a blank page. If I comment out those lines, I get the config page, but when I click save, it throws an error 500 and It doesn't save. I'm getting this messages in the logs:

script '/var/www/html/osticket/scp/sync_mldap.php' not found or unable to stat, referer: https://mydomain/scp/plugins.php?id=10

PHP Fatal error: Uncaught Error: Attempt to assign property "schedule" on null in /var/www/html/osticket/include/plugins/multi-ldap/config.php:57\nStack trace:\n#0 /var/www/html/osticket/include/plugins/multi-ldap/config.php(421): LdapMultiAuthPluginConfig->checkschedule()\n#1 /var/www/html/osticket/include/class.plugin.php(77): LdapMultiAuthPluginConfig->pre_save()\n#2 /var/www/html/osticket/include/class.plugin.php(67): PluginConfig->commitForm()\n#3 /var/www/html/osticket/scp/plugins.php(13): PluginConfig->commit()\n#4 {main}\n thrown in /var/www/html/osticket/include/plugins/multi-ldap/config.php on line 57, referer: https://mydomain/scp/plugins.php?id=10

I'm running:

osTicket - v1.16.2 PHP - 8.0.18 Apache - 2.4.53

philbertphotos commented 2 years ago

The fix was done on PHP 7.4 will now go over the code in PHP 8.0

philbertphotos commented 2 years ago

You may manually have to copy that missing file to the scp folder some how it failed to copy over…

PaysenPetersen commented 2 years ago

Hello, the syncronization doesn't work for me either. The Sync button currently has no function.

When clicking on Sync Users, he gets stuck here.

image

philbertphotos commented 2 years ago

@PaysenPetersen I working on all the bugs right now. Mostly working on PHP 8.0 compatibility had to do a partial rewrite of the code what a pain but its almost finished and doing a few enhancements in tow. The update will be released sometime today in a separate folder until I can make sure its backward compatible and I will make sure the syncing works again.

philbertphotos commented 2 years ago

As for the sync button I am trying to remember if I removed the code because of some previous issue. I will check again before the release.

catalinchertes commented 2 years ago

Thank you so much for dedicating your time and working on this!!

philbertphotos commented 2 years ago

@catalinchertes yea I need to fix it and a few other things that have been nagging me ... currently cleaning up code and removed BS and updating it to work with PHP 8.0 and backwards. Almost done. Hoping to release it soon.

philbertphotos commented 2 years ago

Ok guys try the new update and let me know..

Tested it on both PHP 7.4 and 8.1 and both current versions of Osticket

Sync is working for me (it always did) but now I think I work out the kinks to make sure it adds all the SQL tables it needs.

SamehElsakka commented 2 years ago

Thanks for your time and effort but i installed the new update and still the same issues ,the sync schedule showing January 01 1970 3:00 am even when ticking on Reset/Update schedule on save and the Sync button still have no function at all.

PaysenPetersen commented 2 years ago

Hello, I also installed the update. I also had the problem of Samehelsokka. Despite reinstallation, I had to replace the file /var/www/osticket/upload/scp/sync_mldap.php from the plugin directory. Then it works too. Otherwise I got an HTTP 500 error.

Thank you for your time and effort.

However, I still have a question about the spelling of the password. How do you have to enter the password correctly if you have several domains and thus several passwords.

PaysenPetersen commented 2 years ago

I'm just testing.

The agents can authenticate themselves with the 1 domain via LDAP. However, customers are not syncralized.

image

image

philbertphotos commented 2 years ago

@PaysenPetersen THIS IS PROGRESS! Ok let me check if I can find out why... please check your error and cron logs and send me any errors you may have gotten.

I will check into it and get a update out today ... should be an easy bug to correct.

philbertphotos commented 2 years ago

@PaysenPetersen do me a favor ...go to add new user. If the plugin can properly connect to ldap to get a list of yours then any user not in OSTICKET will come up as remote. You may want to double check you LDAP search string. image

Looking at your image this may not be a bug ...here is the thing I find strange. Why is it not listing the LDAP users. I need to create a visual LDAP check popup button.

PaysenPetersen commented 2 years ago

I just exchanged the version.

image

No remote user appears for me when it comes to the new system. The cron job is running

cron.log May 23 14:57:24 ticketsytem cron[39089]: (CRON) INFO (pidfile fd = 3) May 23 14:57:24 ticketsytem cron[39089]: (CRON) INFO (Skipping @reboot jobs -- not system startup) May 23 15:09:01 ticketsytem CRON[39164]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi) May 23 15:17:01 ticketsytem CRON[40511]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)

I have currently only configured one domain. The syncronization and searches do not work yet.

PaysenPetersen commented 2 years ago

Is it correct that both LDAP modules are active? The standard module is not filled out. image

image

philbertphotos commented 2 years ago

@PaysenPetersen this is concerning... its not searching your LDAP/AD so let me create some visual checks so we can see what is going on. The fact that it authenticates your agents is interesting are you sure you pointing those agents LDAP? image The issue here is AD is not connecting correctly it seems.

philbertphotos commented 2 years ago

Added some debug code and connection test button. Let me know what happens.

image

PaysenPetersen commented 2 years ago
  1. for me the Check Connection Button has no function.

  2. For a colleague, I have set LDAP especially. This works.

  3. This Error Found in osticket_Error.log [Tue May 24 10:31:50.068833 2022] [php:warn] [pid 60057] [client 172.18.97.87:53242] PHP Warning: Undefined array key "sync" in /var/www/osTicket/upload/scp/sync_mldap.php on line 2, referer: http://ticketsystem.jlw-holding.local/scp/plugins.php?id=17

philbertphotos commented 2 years ago

The LDAP service is it Windows AD?

PaysenPetersen commented 2 years ago

Yes, we have Server 2012 R2, Could it be that the comma is a problem in the CN? We use the German version.

philbertphotos commented 2 years ago

@PaysenPetersen could be can you send me a facsimile of the CN that way I can see how different it could be.

catalinchertes commented 2 years ago

Hey @philbertphotos, I downloaded the updated version. To have the check conectivity function working and save button, I had to copy the file sync_mldap.php to /scp folder manually. Now it says that it connected correctly to my domain but the sync function returns 0 users. What could I be doing wrong? Thanks!

catalinchertes commented 2 years ago

executetime: "0:00:00.033" totalagents: 19 totalldap: 0 updatedusers: 0

catalinchertes commented 2 years ago

Same issue here, only agents can authentificate by LDAP, users can't and won't sync.

catalinchertes commented 2 years ago

For me the problem was in the Search User field, I solved that problem by writing it like this: cn=myaduser,cn=Users,dc=Mydomain,dc=local. It now shows that 132 users synced.

{totalldap: 132, totalagents: 19, updatedusers: 124, executetime: '0:00:02.09'}

But I have another problem, If I search for a user that is not registered but exists in my Active Directory, I can see it as (remote) user, but when I click on the user I get this error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) on /scp/ajax.php/select/auth(and a long string with the CN where the user is located and my domain). And after getting this error I get logged out of my account.

If on the other hand I try to log in with an active directory user, it shows the message: "Contact with your administrator to have an account created for you", even with this checkbox marked.

image

Update:

The error in the logs:

PHP Fatal error: Uncaught Error: Call to undefined method LDAPMultiAuthentication::logger() in /var/www/html/osticket/include/plugins/multi-ldap/auth.php:877\nStack trace:\n#0 /var/www/html/osticket/include/ajax.users.php(324): StaffLDAPMultiAuthentication->lookup()\n#1 /var/www/html/osticket/include/class.dispatcher.php(145): UsersAjaxAPI->addRemoteUser()\n#2 /var/www/html/osticket/include/class.dispatcher.php(38): UrlMatcher->dispatch()\n#3 /var/www/html/osticket/include/class.dispatcher.php(120): Dispatcher->resolve()\n#4 /var/www/html/osticket/include/class.dispatcher.php(38): UrlMatcher->dispatch()\n#5 /var/www/html/osticket/scp/ajax.php(316): Dispatcher->resolve()\n#6 {main}\n thrown in /var/www/html/osticket/include/plugins/multi-ldap/auth.php on line 877, referer: https://mysite.com/scp/users.php

philbertphotos commented 2 years ago

@catalinchertes never thought the issue could be the search string .. sounds like the same issue @PaysenPetersen let me look at a few things its hard to pin down since I cant duplicate the problem...never had it and I always sync fine.

philbertphotos commented 2 years ago

Ok fixed the issue in line 877 and it looks like you now syncing users. As for the long string error I think its because of the bug I introduced and hopefully fixed.

philbertphotos commented 2 years ago

As for your search string I dont know how what you do works its not a LDAP string like this (&(objectCategory=person)(objectClass=user)(|(sAMAccountName={q}*)))

e-p-s commented 2 years ago

for me same problem. when i put it into pluginsfolder osticket didnt start anymore. no gui. apache error

philbertphotos commented 2 years ago

@e-p-s show me the error... in the PHP log.

catalinchertes commented 2 years ago

After enabling the plugin, now my user search function is broken and I get this in the console, even after disabling the plugin now the search functionaly is broken on my osticket. image

The other problem I face is that only Agents can authentificate by LDAP, users get the error message: "Contact the administrator to have an account created for you" This users were already created in Osticket and exist in AD.

If there's anything I can do to help you debug the errors let me know.

philbertphotos commented 2 years ago

@e-p-s manually copy the sync_mldap.php to /osticket/upload/scp that would be the only reason for a 404 error. It supposed to copy it on install but sometimes depending on the system it does not. May write something the stops the plugin from enabling unless the file is copied or exists. Would be best to show the PHP error log to be sure.

philbertphotos commented 2 years ago

You need to turn this on like this or user login and creation. existing users are automatically synced/created even if they exist .... but let me test that again I have not in years since I never had a need to do so. image

philbertphotos commented 2 years ago

looks like something changed in this version for client logins so let me check a few things should be an easy fix.

philbertphotos commented 2 years ago

Naaa it works forgot to enable this in the plugin ... make sure you do image