Ldap causing crash on binary
I have this simple program that asks the user to login and then ldap checks their credentials to then proceed in the program. However once I added the ldap and complied it into the .exe any successful logins crashed the program. I compile the program using pip install auto-py-to-exe
and the options I choose are: Onefile, Window Based, and then I name the output.
import sys, ldap from sys import platform if platform == "win32": import win32gui from PyQt5 import QtWidgets from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt class LoginForm(QWidget): def __init__(self, width, height): super().__init__() self.setWindowTitle('Login Form') self.resize(width / 3, height / 3) layout = QGridLayout() label_name = QLabel('<font size="4"> Username: </font>') self.lineEdit_username = QLineEdit() self.lineEdit_username.setPlaceholderText('Please enter ' 'your username') layout.addWidget(label_name, 0, 0) layout.addWidget(self.lineEdit_username, 0, 1) label_password = QLabel('<font size="4"> Password: </font>') self.lineEdit_password = QLineEdit() self.lineEdit_password.setPlaceholderText('Please enter ' 'your password') self.lineEdit_password.setEchoMode(QtWidgets.QLineEdit.Password) layout.addWidget(label_password, 1, 0) layout.addWidget(self.lineEdit_password, 1, 1) button_login = QPushButton('Login') button_login.clicked.connect(self.showApp) layout.addWidget(button_login, 2, 0, 1, 2) layout.setRowMinimumHeight(2, 75) self.setLayout(layout) def checkPass(self): if self.lineEdit_username.text() != '' \ and self.lineEdit_password.text() != '': self.user = self.lineEdit_username.text() conn = ldap.initialize('ldap://ldap.com') conn.protocol_version = 3 conn.set_option(ldap.OPT_REFERRALS, 0) try: result = conn.simple_bind_s(self.user + "@ldap.com", self.lineEdit_password .text()) except ldap.INVALID_CREDENTIALS: return "Invalid credentials" except ldap.SERVER_DOWN: return "Server down" except ldap.LDAPError as e: if type(e.message) == dict and e.message.has_key('desc'): return "Other LDAP error: " + e.message['desc'] else: return "Other LDAP error: " + e finally: conn.unbind_s() return 'Success' def showApp(self): msg = QMessageBox() result = self.checkPass() if result == 'Success': #continue with the program else: msg.setText(result) msg.exec_() if __name__ == '__main__': app = QApplication(sys.argv) screenRes = app.desktop().screenGeometry() width, height = screenRes.width(), screenRes.height() form = LoginForm(width, height) form.show() if win32gui in sys.modules: form.setWindowState(Qt.WindowActive) sys.exit(app.exec_())
Is there something I need to change in my code or in my compiling method? I can not find a good way to debug this.
Edit: I started to screen record the debug window so I can read it after it crashes and it says configparser not found in PYZ
I have also tried doing a --hidden-import=configparser