diff --git a/DomainJoinerInterface.py b/DomainJoinerInterface.py new file mode 100644 index 0000000000000000000000000000000000000000..9d1f99b4afccff57483dbd2f7de85d450c2565ca --- /dev/null +++ b/DomainJoinerInterface.py @@ -0,0 +1,606 @@ +# -*- coding: utf-8 -*- + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import * +from DomainJoinerBackEnd import * + +domainList = list() +domainNameList = list() +resimEkle = list() + +# Main Window Interface Code + +class Ui_Dialog(object): + def setupUi(self, Dialog): + Dialog.setObjectName("Dialog") + Dialog.setEnabled(True) + Dialog.setFixedSize(500, 460) + Dialog.setAutoFillBackground(False) + Dialog.setStyleSheet("QMainWindow\n" + "{\n" + "background-image: url('arkaplan_1.png');\n" + "}") + self.horizontalLayoutWidget_2 = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(20, 110, 161, 22)) + self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2") + self.HL2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2) + self.HL2.setContentsMargins(0, 0, 0, 0) + self.HL2.setObjectName("HL2") + self.cnameLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_2) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(246, 246, 245)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(159, 159, 157)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(246, 246, 245)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(246, 246, 245)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(159, 159, 157)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(246, 246, 245)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(246, 246, 245)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(159, 159, 157)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(119, 119, 118)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(238, 238, 236)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) + self.cnameLabel.setPalette(palette) + font = QtGui.QFont() + font.setFamily("URW Gothic L") + font.setPointSize(11) + font.setBold(True) + font.setWeight(75) + self.cnameLabel.setFont(font) + self.cnameLabel.setObjectName("cnameLabel") + self.HL2.addWidget(self.cnameLabel) + self.horizontalLayoutWidget_3 = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(20, 140, 461, 31)) + self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3") + self.HL3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3) + self.HL3.setContentsMargins(0, 0, 0, 0) + self.HL3.setObjectName("HL3") + self.newcnameLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_3) + font = QtGui.QFont() + font.setFamily("URW Gothic L") + font.setPointSize(11) + font.setBold(True) + font.setWeight(75) + self.newcnameLabel.setFont(font) + self.newcnameLabel.setObjectName("newcnameLabel") + self.HL3.addWidget(self.newcnameLabel) + self.newcname = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3) + self.newcname.setObjectName("newcname") + self.HL3.addWidget(self.newcname) + self.horizontalLayoutWidget_4 = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(20, 180, 461, 221)) + self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4") + self.HL4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4) + self.HL4.setContentsMargins(0, 0, 0, 0) + self.HL4.setObjectName("HL4") + self.membershipof = QtWidgets.QGroupBox(self.horizontalLayoutWidget_4) + self.membershipof.setTitle("") + self.membershipof.setObjectName("membershipof") + self.localRadio = QtWidgets.QRadioButton(self.membershipof) + self.localRadio.setGeometry(QtCore.QRect(10, 30, 101, 20)) + self.localRadio.setStyleSheet("QRadioButton\n" + "{\n" + "color: #6f85e4;\n" + "font-weight: bold;\n" + "}") + self.localRadio.setObjectName("localRadio") + self.domainRadio = QtWidgets.QRadioButton(self.membershipof) + self.domainRadio.setGeometry(QtCore.QRect(10, 100, 101, 20)) + self.domainRadio.setStyleSheet("QRadioButton\n" + "{\n" + "color: #6f85e4;\n" + "font-weight: bold;\n" + "}") + self.domainRadio.setObjectName("domainRadio") + self.localLabel = QtWidgets.QLabel(self.membershipof) + self.localLabel.setGeometry(QtCore.QRect(30, 50, 421, 41)) + self.localLabel.setOpenExternalLinks(False) + self.localLabel.setObjectName("localLabel") + self.domainname = QtWidgets.QLineEdit(self.membershipof) + self.domainname.setGeometry(QtCore.QRect(30, 120, 411, 21)) + self.domainname.setObjectName("domainname") + self.domainLabel = QtWidgets.QLabel(self.membershipof) + self.domainLabel.setGeometry(QtCore.QRect(30, 140, 411, 71)) + self.domainLabel.setObjectName("domainLabel") + self.verticalLayoutWidget = QtWidgets.QWidget(self.membershipof) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 114, 22)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.membershipofLabel = QtWidgets.QLabel(self.verticalLayoutWidget) + font = QtGui.QFont() + font.setFamily("URW Gothic L") + font.setPointSize(11) + font.setBold(True) + font.setWeight(75) + self.membershipofLabel.setFont(font) + self.membershipofLabel.setObjectName("membershipofLabel") + self.verticalLayout_2.addWidget(self.membershipofLabel) + self.localLabel.raise_() + self.localRadio.raise_() + self.domainname.raise_() + self.domainRadio.raise_() + self.domainLabel.raise_() + self.verticalLayoutWidget.raise_() + self.HL4.addWidget(self.membershipof) + self.horizontalLayoutWidget = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget.setGeometry(QtCore.QRect(20, 410, 461, 31)) + self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") + self.HL5 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget) + self.HL5.setContentsMargins(0, 0, 0, 0) + self.HL5.setObjectName("HL5") + self.confirmButton = QtWidgets.QPushButton(self.horizontalLayoutWidget) + self.confirmButton.setObjectName("confirmButton") + self.HL5.addWidget(self.confirmButton) + self.cancelButton = QtWidgets.QPushButton(self.horizontalLayoutWidget) + self.cancelButton.setObjectName("cancelButton") + self.HL5.addWidget(self.cancelButton) + self.horizontalLayoutWidget_5 = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(20, 10, 461, 102)) + self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5") + self.HL1 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5) + self.HL1.setContentsMargins(0, 0, 0, 0) + self.HL1.setObjectName("HL1") + self.firstLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_5) + self.firstLabel.setObjectName("firstLabel") + self.HL1.addWidget(self.firstLabel) + self.logoLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_5) + self.logoLabel.setMaximumSize(QtCore.QSize(100, 100)) + self.logoLabel.setAutoFillBackground(False) + self.logoLabel.setText("") + self.logoLabel.setScaledContents(True) + self.logoLabel.setAlignment(QtCore.Qt.AlignCenter) + self.logoLabel.setObjectName("logoLabel") + self.HL1.addWidget(self.logoLabel) + self.horizontalLayoutWidget_6 = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(190, 110, 291, 21)) + self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6") + self.HL2_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6) + self.HL2_2.setContentsMargins(0, 0, 0, 0) + self.HL2_2.setObjectName("HL2_2") + self.cname = QtWidgets.QLabel(self.horizontalLayoutWidget_6) + self.cname.setStyleSheet("QLabel\n" + "{\n" + "color: white\n" + "}") + self.cname.setObjectName("cname") + self.HL2_2.addWidget(self.cname) + + + + # Adding Action and Events + self.domainRadio.toggled.connect(self.domainRadio_clicked) + self.confirmButton.clicked.connect(self.confirmButtonAction) + self.cancelButton.clicked.connect(app.exit) + self.localordomain() + + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) + + def retranslateUi(self, Dialog): + _translate = QtCore.QCoreApplication.translate + Dialog.setWindowTitle(_translate("Dialog", "Domain Joiner")) + self.cnameLabel.setText(_translate("Dialog", + "<html><head/><body><p><span style=\" color:#eeeeec;\">Computer Name:</span></p></body></html>")) + self.newcnameLabel.setText(_translate("Dialog", + "<html><head/><body><p><span style=\" color:#eeeeec;\">New Computer Name:</span></p></body></html>")) + self.localRadio.setText(_translate("Dialog", "Local")) + self.domainRadio.setText(_translate("Dialog", "Domain")) + self.localLabel.setText(_translate("Dialog", + "<html><head/><body><p><span style=\" font-size:8pt; color:#888a85;\">Choose local if you aren\'t a system administrator. Thus, you will change</span></p><p><span style=\" font-size:8pt; color:#888a85;\">only computer name.</span></p></body></html>")) + self.domainLabel.setText(_translate("Dialog", + "<html><head/><body><p align=\"justify\"><span style=\" font-size:8pt; color:#888a85;\">All necessary configuration files will be reconfigured if a new domain</span></p><p align=\"justify\"><span style=\" font-size:8pt; color:#888a85;\">address is chosen as domain then an authorized user will be asked to</span></p><p align=\"justify\"><span style=\" font-size:8pt; color:#888a85;\">login to add the system to new domain.</span></p></body></html>")) + self.membershipofLabel.setText(_translate("Dialog", + "<html><head/><body><p><span style=\" color:#eeeeec;\">Membership of</span></p></body></html>")) + self.confirmButton.setText(_translate("Dialog", "Confirm")) + self.cancelButton.setText(_translate("Dialog", "Cancel")) + self.firstLabel.setText(_translate("Dialog", + "<html><head/><body><p><span style=\" color:#ffffff;\">Enter a new computer name or do not make any</span></p><p><span style=\" color:#ffffff;\">changes to keep using the same computer name.</span></p></body></html>")) + computer_name = str(gethostname()) + cn1 = computer_name.replace("b'", "") + cn2 = cn1[:-3] + self.cname.setText(_translate("Dialog", str(cn2))) + # Main Window Action Functions Code + + # This function determines whether the user is in local or domain when the screen is first opened. + def localordomain(self): + a = list() + sonuc = LocalorDomain() + a.append(sonuc) + if (sonuc == False): # For Local + domainNameList.clear() + self.localRadio.setChecked(True) + domainNameList.append(" ") + self.logoLabel.setPixmap(QtGui.QPixmap("Local-icon.png")) + elif (sonuc == True): # For Domain + domainNameList.clear() + realmname = realmnameUpper() + liste = str(realmname).split(": ") + self.domainname.setText(liste[1][:-3]) + domainNameList.append(liste[1][:-3]) + self.domainRadio.setChecked(True) + self.logoLabel.setPixmap(QtGui.QPixmap("Domain-icon.png")) + + # This function determines the domain line edit activity. + def domainRadio_clicked(self): + if (self.domainRadio.isChecked() == True): + self.domainname.setEnabled(True) + else: + self.domainname.setEnabled(False) + + # This function determines "Confirm" button actions and events. + def confirmButtonAction(self): + if (self.localRadio.isChecked() == True): + if (self.newcname.text().isspace() == True or self.newcname.text() == ""): + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Critical) + msg.setWindowIcon(self.icon) + msg.setText("Local name can't be empty!") + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + else: + if (checkHostname(self.newcname.text(), self.cname.text()) == True): + addDomainExt(self.newcname.text(), "None") + self.domainname.clear() + leave = leaveDomain() + self.logoLabel.setPixmap(QtGui.QPixmap("Local-icon.png")) + if (leave == True): + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Information) + msg.setWindowIcon(self.icon) + msg.setText("You leaved domain and updated domain name for local.") + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + else: + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Critical) + msg.setWindowIcon(self.icon) + msg.setText("You don't leave domain.") + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + + self.cname.setText(self.newcname.text()) + else: + message = "That is already your local name." + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Information) + msg.setWindowIcon(self.icon) + msg.setText(message) + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + + self.newcname.clear() + + elif (self.domainRadio.isChecked() == True): + if (self.domainname.text().isspace() == True or self.domainname.text() == ""): + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Critical) + msg.setWindowIcon(self.icon) + msg.setText("Domain can't be empty!") + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + + else: + domainNameList.clear() + realmnames = realmnameUpper() + liste1 = str(realmnames).split(": ") + print(liste1) + if (liste1[0] != "b''"): + domainNameList.append(liste1[1][:-3]) + if (checkHostname(self.domainname.text().upper(), domainNameList[0]) == True): + realmNameUpper = self.domainname.text().upper() + self.domainname.setText(realmNameUpper) + domainList.append(self.domainname.text()) + Dialog = QDialog() + ui = Ui_UserLogin() + ui.setupUi2(Dialog) + Dialog.show() + Dialog.exec_() + if (len(resimEkle) != 0): + if (resimEkle[0] == True): + self.logoLabel.setPixmap(QtGui.QPixmap("Domain-icon.png")) + else: + message = "You are already in this domain." + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Information) + msg.setWindowIcon(self.icon) + msg.setText(message) + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + return + elif(liste1[0] == "b''"): + realmNameUpper = self.domainname.text().upper() + self.domainname.setText(realmNameUpper) + domainList.append(self.domainname.text()) + Dialog = QDialog() + ui = Ui_UserLogin() + ui.setupUi2(Dialog) + Dialog.show() + Dialog.exec_() + if(len(resimEkle) != 0): + if (resimEkle[0] == True): + self.logoLabel.setPixmap(QtGui.QPixmap("Domain-icon.png")) + + +# User Authentication Window Interface Code + +class Ui_UserLogin(object): + def setupUi2(self, UserLogin): + UserLogin.setObjectName("UserLogin") + UserLogin.setFixedSize(361, 344) + UserLogin.setStyleSheet("QDialog\n" + "{\n" + "background-image: url('login.png');\n" + "}") + self.horizontalLayoutWidget_2 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(30, 230, 91, 21)) + self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2") + self.HL2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2) + self.HL2.setContentsMargins(0, 0, 0, 0) + self.HL2.setObjectName("HL2") + self.usernameLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_2) + self.usernameLabel.setObjectName("usernameLabel") + self.HL2.addWidget(self.usernameLabel) + self.usernameLabel.setStyleSheet("color:white;") + self.horizontalLayoutWidget_6 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(130, 230, 181, 25)) + self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6") + self.HL2_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6) + self.HL2_2.setContentsMargins(0, 0, 0, 0) + self.HL2_2.setObjectName("HL2_2") + self.username = QtWidgets.QLineEdit(self.horizontalLayoutWidget_6) + self.username.setFocusPolicy(QtCore.Qt.WheelFocus) + self.username.setObjectName("username") + self.HL2_2.addWidget(self.username) + self.horizontalLayoutWidget_3 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(30, 260, 91, 21)) + self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3") + self.HL2_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3) + self.HL2_3.setContentsMargins(0, 0, 0, 0) + self.HL2_3.setObjectName("HL2_3") + self.passwordLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_3) + self.passwordLabel.setObjectName("passwordLabel") + self.HL2_3.addWidget(self.passwordLabel) + self.passwordLabel.setStyleSheet("color:white;") + self.horizontalLayoutWidget_7 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_7.setGeometry(QtCore.QRect(130, 260, 181, 25)) + self.horizontalLayoutWidget_7.setObjectName("horizontalLayoutWidget_7") + self.HL2_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_7) + self.HL2_4.setContentsMargins(0, 0, 0, 0) + self.HL2_4.setObjectName("HL2_4") + self.password = QtWidgets.QLineEdit(self.horizontalLayoutWidget_7) + self.password.setEchoMode(QtWidgets.QLineEdit.Password) + self.password.setObjectName("password") + self.HL2_4.addWidget(self.password) + self.horizontalLayoutWidget = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget.setGeometry(QtCore.QRect(110, 20, 152, 152)) + self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget) + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.imageLabel = QtWidgets.QLabel(self.horizontalLayoutWidget) + self.imageLabel.setMaximumSize(QtCore.QSize(125, 125)) + self.imageLabel.setText("") + self.imageLabel.setPixmap(QtGui.QPixmap("/home/test/Masaüstü/a.png")) + self.imageLabel.setScaledContents(True) + self.imageLabel.setAlignment(QtCore.Qt.AlignCenter) + self.imageLabel.setObjectName("imageLabel") + self.horizontalLayout.addWidget(self.imageLabel) + self.horizontalLayoutWidget_4 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(20, 170, 311, 44)) + self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4") + self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4) + self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.pleaseLabel = QtWidgets.QLabel(self.horizontalLayoutWidget_4) + self.pleaseLabel.setObjectName("pleaseLabel") + self.horizontalLayout_2.addWidget(self.pleaseLabel) + self.pleaseLabel.setStyleSheet("color:white;") + self.horizontalLayoutWidget_5 = QtWidgets.QWidget(UserLogin) + self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(130, 290, 181, 31)) + self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5) + self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.loginButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_5) + self.loginButton.setObjectName("loginButton") + self.horizontalLayout_3.addWidget(self.loginButton) + self.horizontalLayoutWidget_2.raise_() + self.horizontalLayoutWidget_6.raise_() + self.horizontalLayoutWidget_3.raise_() + self.horizontalLayoutWidget_7.raise_() + self.horizontalLayoutWidget.raise_() + self.imageLabel.raise_() + self.horizontalLayoutWidget_4.raise_() + self.horizontalLayoutWidget_5.raise_() + self.pleaseLabel.raise_() + + # Adding Action and Events + self.loginButton.clicked.connect(self.loginButtonAction) + + self.retranslateUi(UserLogin) + QtCore.QMetaObject.connectSlotsByName(UserLogin) + + def retranslateUi(self, UserLogin): + _translate = QtCore.QCoreApplication.translate + UserLogin.setWindowTitle(_translate("UserLogin", "Domain Joiner")) + self.usernameLabel.setText(_translate("UserLogin", + "<html><head/><body><p align=\"right\"><span style=\" font-weight:600;\">Username:</span></p></body></html>")) + self.passwordLabel.setText(_translate("UserLogin", + "<html><head/><body><p align=\"right\"><span style=\" font-weight:600;\">Password:</span></p></body></html>")) + self.pleaseLabel.setText(_translate("UserLogin", + "<html><head/><body><p align=\"center\">Please login with username and password</p><p align=\"center\">for user authentication.</p></body></html>")) + self.loginButton.setText(_translate("UserLogin", "Login")) + + # This function determines "Login" button action and events. + def loginButtonAction(self): + hostnameParameter = gethostname() + message = checkUsernamePasswordDomain(self.password.text(), self.username.text(), domainList[0]) + if(message == "Domain is not found!" or message == "Username or Password is wrong!"): + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Critical) + msg.setWindowIcon(self.icon) + msg.setText(message) + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.exec_() + elif (message == "You joined to domain!"): + msg = QMessageBox() + self.icon = QtGui.QIcon() + msg.setIcon(QMessageBox.Information) + msg.setWindowIcon(self.icon) + msg.setText(message) + msg.setWindowTitle("Info") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + resimEkle.append(True) + msg.exec_() + + + + + +if __name__ == "__main__": + import sys + app = QApplication(sys.argv) + MainWindow = QMainWindow() + ui = Ui_Dialog() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_())