1 /***************************************************************************
2 smbpasswdfile.h - description
4 begin : Tue June 6 2002
5 copyright : (C) 2002 by Jan Schäfer
6 email : janschaefer@users.sourceforge.net
7 ***************************************************************************/
9 /******************************************************************************
11 * This file is part of KSambaPlugin. *
13 * KSambaPlugin is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
18 * KSambaPlugin is distributed in the hope that it will be useful, *
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21 * GNU General Public License for more details. *
23 * You should have received a copy of the GNU General Public License *
24 * along with KSambaPlugin; if not, write to the Free Software *
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
27 ******************************************************************************/
29 #ifndef SMBPASSWDFILE_H
30 #define SMBPASSWDFILE_H
46 * Simple class to store a Samba User
51 SambaUser(const QString
& aName
= QString(), int anUid
= -1) {name
= aName
; uid
= anUid
;}
59 bool isWorkstationTrustAccount
;
63 * A QPtrList of SambaUser
65 class SambaUserList
: public Q3PtrList
<SambaUser
>
68 QStringList
getUserNames();
72 * This class represents the SAMBA smbpasswd file.
74 * - getting a list of all SAMBA users
75 * - adding a new user -> uses smbpasswd program
76 * - removing an existing user -> uses smbpasswd program
78 class SmbPasswdFile
: public QObject
83 SmbPasswdFile(const KUrl
&);
86 void setUrl(const KUrl
&);
89 * Returns a list of all users stored in
92 SambaUserList
getSambaUserList();
95 * Calls smbpasswd with the given arguments
97 bool executeSmbpasswd(const QStringList
& args
);
100 * Tries to add the passed user to the smbpasswd file
101 * returns true if successful otherwise false
103 bool addUser(const SambaUser
&, const QString
& password
);
106 * Tries to remove the passed user from the smbpasswd file
107 * returns true if successful otherwise false
109 bool removeUser(const SambaUser
&);
112 * Tries to change the password of the passed user
113 * if it fails returns false otherwise true
115 bool changePassword(const SambaUser
&, const QString
& password
);
117 bool enableUser(const SambaUser
&);
119 bool disableUser(const SambaUser
&);
121 bool setNoPassword(const SambaUser
&);
123 bool setMachineTrustAccount(const SambaUser
&);
125 bool joinADomain(const QString
&, const QString
&, const QString
&, const QString
&);
128 * Returns the Url of the smbpasswd file
129 * specified in the [global] section of
131 * If there is no entry in the [global] section
132 * it tries to guess the location.
134 static KUrl
getUrlFromSambaFile(const SambaFile
*file
);
137 QString _smbpasswdOutput
;
140 void smbpasswdStdOutReceived(K3Process
*,char*,int);