I had this issue with a drive mapping app i create not mapping drives at initial login for AD accounts (this app will be discussed in another post shortly).
The Apple KB with the same title as this post advises how to fix, but if you wish to script it do the following:
WARNING: TEST, TEST, TEST THIS. ADDING AN EXTRA CHARACTER CAN LEAD TO YOUR MAC BEING STUCK IN A LOGIN LOOP. THE BELOW SHOULD BE ENTERED ON 2 LINES