snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

How to sync LDAP users using command line like "php artisan snipeit:ldap-sync" command line?

Open itims opened this issue 9 years ago • 9 comments

Hi, I am getting an error like "Could not open input file: artisan" when I sync LDAP users from AD into Snipe-IT using CLI (php artisan snipeit:ldap-sync). But I can sync LDAP with no error using GUI and the LDAP function works fine.

Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running - 3.6.3
  • What OS and web server you're running Snipe-IT on - Ubuntu 14.04 and Apache2
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - install.sh
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
  • If a stacktrace is provided in the error, include that too.
  • Any errors that appear in your browser's error console.
  • Confirm whether the error is reproduceable on the demo.
  • Include any additional information you can find in app/storage/logs and your webserver's logs.
  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database

itims avatar Sep 14 '17 12:09 itims

What is the directory where your snipe-it install lives, and what directory are you running the artisan command from?

snipe avatar Sep 14 '17 21:09 snipe

Hi, I got your point:-), Thank you snipe. Now I can run the artisan command from the snipe-it directory (admin@ams:/var/www/snipeit$ php artisan snipeit:ldap-sync) and it's working good. How can I create a php script file with command ''artisan snipeit:ldap-sync" ?. I need to set up a cron to automatically sync LDAP.

itims avatar Sep 15 '17 04:09 itims

This is useful. I will need to look into this further.

For the cronjob you can probably use the following based on the path you provided above. 0 0 * * * /usr/bin/php /var/www/snipeit/artisan snipeit:ldap-sync >> /dev/null 2>&1

tiagom62 avatar Sep 25 '17 23:09 tiagom62

@itims yeah, you wouldn't want to write a PHP script to call that command, since it's already a command line script. It would just be an extra layer that doesn't actually do anything. The cron command @tiagom62 stated above should do the trick.

snipe avatar Sep 25 '17 23:09 snipe

I know this is an old thread, but is this expected to work with Docker?

As running the commands individually inside the container work fine of course, but placing anything in any of the cron (cron.d, cron.daily, cron.weekly) folders do not seem to work.

delize avatar May 08 '18 20:05 delize

I know this is an old thread, but is this expected to work with Docker?

As running the commands individually inside the container work fine of course, but placing anything in any of the cron (cron.d, cron.daily, cron.weekly) folders do not seem to work.

What command are you running inside the container to do an ldap sync manually? I'm not able to get this working.

SpartacusIam avatar Apr 20 '21 20:04 SpartacusIam

Did you figure it out?

SonGokussj4 avatar Apr 13 '22 08:04 SonGokussj4

@SonGokussj4 & @SpartacusIam we setup a custom cronjob and volume mounted it that would trigger the sync.

I don't have the command/script anymore (I no longer work there). But given that this is 4 years old, I am not sure it would still in fact work.

I would recommend you look at the SCIM functionality that was just released instead.

delize avatar May 18 '22 22:05 delize

[ SOLVED ] Finally solved here with a cronjob to make it automatical too: #8475

SonGokussj4 avatar Oct 11 '22 15:10 SonGokussj4