mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
removed ldap and samba support for kuser
This commit is contained in:
parent
5cca49d4ac
commit
7f2ec9d5be
12 changed files with 2 additions and 1944 deletions
|
@ -12,8 +12,6 @@ add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
|||
|
||||
include_directories (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
|
||||
|
||||
find_package(KdepimLibs REQUIRED)
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
|
@ -73,8 +71,6 @@ set(kuser_SRCS
|
|||
sid.cpp
|
||||
ku_userfiles.cpp
|
||||
ku_groupfiles.cpp
|
||||
ku_userldap.cpp
|
||||
ku_groupldap.cpp
|
||||
ku_usersystem.cpp
|
||||
ku_groupsystem.cpp
|
||||
ku_selectconn.cpp
|
||||
|
@ -82,7 +78,7 @@ set(kuser_SRCS
|
|||
|
||||
kde4_add_kcfg_files(kuser_SRCS ku_prefs.kcfgc)
|
||||
|
||||
kde4_add_ui_files(kuser_SRCS ku_filessettings.ui ku_generalsettings.ui ku_ldapsettings.ui ku_ldapsamba.ui ku_passwordpolicy.ui)
|
||||
kde4_add_ui_files(kuser_SRCS ku_filessettings.ui ku_generalsettings.ui ku_passwordpolicy.ui)
|
||||
|
||||
kde4_add_executable(kuser ${kuser_SRCS})
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <knuminput.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <ktabwidget.h>
|
||||
#include <kldap/ldapconfigwidget.h>
|
||||
#include <kldap/ldapurl.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "ku_configdlg.h"
|
||||
|
@ -36,12 +34,10 @@
|
|||
|
||||
#include "ui_ku_generalsettings.h"
|
||||
#include "ui_ku_filessettings.h"
|
||||
#include "ui_ku_ldapsettings.h"
|
||||
#include "ui_ku_ldapsamba.h"
|
||||
#include "ui_ku_passwordpolicy.h"
|
||||
|
||||
KU_ConfigDlg::KU_ConfigDlg( KConfigSkeleton *config, QWidget *parent, const char *name ) :
|
||||
KConfigDialog( parent, QLatin1String( name ), config),sambaui(0)
|
||||
KConfigDialog( parent, QLatin1String( name ), config)
|
||||
{
|
||||
setFaceType(List);
|
||||
setButtons(Default|Ok|Apply|Cancel|Help);
|
||||
|
@ -75,153 +71,12 @@ KU_ConfigDlg::KU_ConfigDlg( KConfigSkeleton *config, QWidget *parent, const char
|
|||
addPage( page2, i18n("Files"), QLatin1String( "document-properties" ), i18n("File Source Settings") );
|
||||
}
|
||||
|
||||
KTabWidget *page3 = new KTabWidget( this );
|
||||
|
||||
ldconf =
|
||||
new KLDAP::LdapConfigWidget(
|
||||
KLDAP::LdapConfigWidget::W_USER |
|
||||
KLDAP::LdapConfigWidget::W_PASS |
|
||||
KLDAP::LdapConfigWidget::W_BINDDN |
|
||||
KLDAP::LdapConfigWidget::W_REALM |
|
||||
KLDAP::LdapConfigWidget::W_HOST |
|
||||
KLDAP::LdapConfigWidget::W_PORT |
|
||||
KLDAP::LdapConfigWidget::W_VER |
|
||||
KLDAP::LdapConfigWidget::W_DN |
|
||||
KLDAP::LdapConfigWidget::W_SECBOX |
|
||||
KLDAP::LdapConfigWidget::W_AUTHBOX |
|
||||
KLDAP::LdapConfigWidget::W_TIMELIMIT |
|
||||
KLDAP::LdapConfigWidget::W_SIZELIMIT |
|
||||
KLDAP::LdapConfigWidget::W_PAGESIZE,
|
||||
0 );
|
||||
|
||||
page3->addTab( ldconf, i18n("Connection") );
|
||||
|
||||
{
|
||||
QFrame *page3b = new QFrame( 0 );
|
||||
ldapui = new Ui::KU_LdapSettings();
|
||||
ldapui->setupUi( page3b );
|
||||
page3->addTab( page3b, i18n("Settings") );
|
||||
}
|
||||
{
|
||||
QFrame *page3c = new QFrame( 0 );
|
||||
sambaui = new Ui::KU_LdapSamba();
|
||||
sambaui->setupUi( page3c );
|
||||
connect( sambaui->domQuery, SIGNAL(clicked()), SLOT(slotQueryClicked()) );
|
||||
page3->addTab( page3c, i18n("Samba") );
|
||||
}
|
||||
addPage( page3, i18n("LDAP"), QLatin1String( "network-server-database" ), i18n("LDAP Source Settings") );
|
||||
setHelp(QString(),QLatin1String( "kuser" ));
|
||||
}
|
||||
|
||||
KU_ConfigDlg::~KU_ConfigDlg()
|
||||
{
|
||||
delete sambaui;
|
||||
delete ldapui;
|
||||
delete fileui;
|
||||
}
|
||||
|
||||
void KU_ConfigDlg::slotQueryClicked()
|
||||
{
|
||||
|
||||
KLDAP::LdapUrl _url = ldconf->url();
|
||||
|
||||
mResult.clear();
|
||||
mDomain.name.clear();
|
||||
mDomain.sid.clear();
|
||||
mDomain.ridbase = 1000;
|
||||
|
||||
QStringList attrs;
|
||||
QString filter = QLatin1String( "(objectClass=sambaDomain)" );
|
||||
QString dom = sambaui->kcfg_samdomain->text();
|
||||
if ( !dom.isEmpty() ) filter = QLatin1String( "(&(sambaDomainName=" ) + dom + QLatin1Char( ')' ) + filter + QLatin1Char( ')' );
|
||||
attrs.append(QLatin1String( "sambaDomainName" ));
|
||||
attrs.append(QLatin1String( "sambaSID" ));
|
||||
attrs.append(QLatin1String( "sambaAlgorithmicRidBase" ));
|
||||
_url.setAttributes( attrs );
|
||||
_url.setScope( KLDAP::LdapUrl::One );
|
||||
_url.setExtension( QLatin1String( "x-dir" ), QLatin1String( "base" ) );
|
||||
_url.setFilter( filter );
|
||||
|
||||
kDebug() << "sendQuery url: " << _url.prettyUrl();
|
||||
mLdif.startParsing();
|
||||
KIO::Job *job = KIO::get( _url, KIO::Reload, KIO::HideProgressInfo );
|
||||
// job->addMetaData("no-auth-prompt","true");
|
||||
connect( job, SIGNAL(data(KIO::Job*,QByteArray)),
|
||||
this, SLOT(loadData(KIO::Job*,QByteArray)) );
|
||||
connect( job, SIGNAL(result(KJob*)),
|
||||
this, SLOT(loadResult(KJob*)) );
|
||||
|
||||
mProg = new QProgressDialog( 0 );
|
||||
mProg->setLabel( new QLabel(_url.prettyUrl()) );
|
||||
mProg->setValue( 0 );
|
||||
mProg->setMaximum( 1 );
|
||||
mProg->setAutoClose( false );
|
||||
mProg->setAutoReset( false );
|
||||
mProg->exec();
|
||||
if ( mProg->wasCanceled() ) {
|
||||
kDebug() << "query cancelled!";
|
||||
job->kill( KJob::Quietly );
|
||||
} else {
|
||||
if ( !mErrorMsg.isEmpty() )
|
||||
KMessageBox::error( this, mErrorMsg );
|
||||
else {
|
||||
if ( !mResult.isEmpty() ) {
|
||||
mDomain = mResult.first();
|
||||
if ( !mDomain.name.isEmpty() && !mDomain.sid.isEmpty() ) {
|
||||
sambaui->kcfg_samdomain->setText( mDomain.name );
|
||||
sambaui->kcfg_samdomsid->setText( mDomain.sid );
|
||||
sambaui->kcfg_samridbase->setValue( mDomain.ridbase );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete mProg;
|
||||
kDebug() << "domQueryx";
|
||||
|
||||
}
|
||||
|
||||
void KU_ConfigDlg::loadData( KIO::Job*, const QByteArray& d )
|
||||
{
|
||||
KLDAP::Ldif::ParseValue ret;
|
||||
|
||||
if ( d.size() ) {
|
||||
mLdif.setLdif( d );
|
||||
} else {
|
||||
mLdif.endLdif();
|
||||
}
|
||||
do {
|
||||
ret = mLdif.nextItem();
|
||||
switch ( ret ) {
|
||||
case KLDAP::Ldif::Item:
|
||||
if ( mLdif.attr() == QLatin1String( "sambaDomainName" ) )
|
||||
mDomain.name = QString::fromUtf8( mLdif.value(), mLdif.value().size() );
|
||||
else if ( mLdif.attr() == QLatin1String( "sambaSID" ) )
|
||||
mDomain.sid = QString::fromUtf8( mLdif.value(), mLdif.value().size() );
|
||||
else if ( mLdif.attr() == QLatin1String( "sambaAlgorithmicRidBase" ) )
|
||||
mDomain.ridbase = QString::fromUtf8( mLdif.value(), mLdif.value().size() ).toUInt();
|
||||
break;
|
||||
case KLDAP::Ldif::EndEntry:
|
||||
mProg->setValue( 1 );
|
||||
if ( !mDomain.name.isEmpty() && !mDomain.sid.isEmpty() )
|
||||
mResult.push_back( mDomain );
|
||||
mDomain.sid.clear();
|
||||
mDomain.name.clear();
|
||||
mDomain.ridbase = 1000;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} while ( ret != KLDAP::Ldif::MoreData );
|
||||
}
|
||||
|
||||
void KU_ConfigDlg::loadResult( KJob* job)
|
||||
{
|
||||
int error = job->error();
|
||||
if ( error && error != KIO::ERR_USER_CANCELED )
|
||||
mErrorMsg = job->errorString();
|
||||
else
|
||||
mErrorMsg = QLatin1String( "" );
|
||||
|
||||
mProg->hide();
|
||||
}
|
||||
|
||||
#include "ku_configdlg.moc"
|
||||
|
|
|
@ -26,20 +26,11 @@
|
|||
#include <QProgressDialog>
|
||||
|
||||
#include <kconfigdialog.h>
|
||||
#include <kldap/ldif.h>
|
||||
#include <kprogressdialog.h>
|
||||
#include <kio/job.h>
|
||||
|
||||
class Ui_KU_LdapSamba;
|
||||
class Ui_KU_LdapSettings;
|
||||
class Ui_KU_FilesSettings;
|
||||
namespace KLDAP { class LdapConfigWidget; }
|
||||
namespace KIO { class Job; }
|
||||
struct KU_SambaDomain {
|
||||
QString name;
|
||||
QString sid;
|
||||
uint ridbase;
|
||||
};
|
||||
|
||||
class KU_ConfigDlg : public KConfigDialog {
|
||||
Q_OBJECT
|
||||
|
@ -48,18 +39,8 @@ public:
|
|||
~KU_ConfigDlg();
|
||||
private:
|
||||
QProgressDialog *mProg;
|
||||
Ui_KU_LdapSamba *sambaui;
|
||||
Ui_KU_LdapSettings *ldapui;
|
||||
Ui_KU_FilesSettings *fileui;
|
||||
KLDAP::LdapConfigWidget *ldconf;
|
||||
KLDAP::Ldif mLdif;
|
||||
QString mErrorMsg;
|
||||
QList<KU_SambaDomain> mResult;
|
||||
KU_SambaDomain mDomain;
|
||||
private slots:
|
||||
void slotQueryClicked();
|
||||
void loadData( KIO::Job*, const QByteArray& d );
|
||||
void loadResult( KJob* job);
|
||||
};
|
||||
|
||||
#endif // _KU_CONFIGDLG_H_
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "ku_global.h"
|
||||
#include "ku_userfiles.h"
|
||||
#include "ku_groupfiles.h"
|
||||
#include "ku_userldap.h"
|
||||
#include "ku_groupldap.h"
|
||||
#include "ku_usersystem.h"
|
||||
#include "ku_groupsystem.h"
|
||||
|
||||
|
@ -69,10 +67,6 @@ void KU_Global::init()
|
|||
mUsers = new KU_UserFiles( mCfg );
|
||||
mGroups = new KU_GroupFiles( mCfg );
|
||||
break;
|
||||
case KU_PrefsBase::EnumSource::LDAP:
|
||||
mUsers = new KU_UserLDAP( mCfg );
|
||||
mGroups = new KU_GroupLDAP( mCfg );
|
||||
break;
|
||||
case KU_PrefsBase::EnumSource::System:
|
||||
mUsers = new KU_UserSystem( mCfg );
|
||||
mGroups = new KU_GroupSystem( mCfg );
|
||||
|
|
|
@ -1,312 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kldap/ldapdefs.h>
|
||||
|
||||
#include "ku_groupldap.h"
|
||||
#include "ku_misc.h"
|
||||
|
||||
KU_GroupLDAP::KU_GroupLDAP( KU_PrefsBase *cfg ) : KU_Groups( cfg )
|
||||
{
|
||||
if ( mCfg->ldapssl() )
|
||||
mUrl.setProtocol(QLatin1String( "ldaps" ));
|
||||
else
|
||||
mUrl.setProtocol(QLatin1String( "ldap" ));
|
||||
|
||||
mUrl.setHost( mCfg->ldaphost() );
|
||||
mUrl.setPort( mCfg->ldapport() );
|
||||
mUrl.setDn( KLDAP::LdapDN( mCfg->ldapgroupbase() + QLatin1Char( ',' ) + mCfg->ldapdn() ) );
|
||||
if ( !mCfg->ldapanon() ) {
|
||||
mUrl.setUser( mCfg->ldapuser() );
|
||||
mUrl.setPass( mCfg->ldappassword() );
|
||||
QString binddn = mCfg->ldapbinddn();
|
||||
if ( !binddn.isEmpty() )
|
||||
mUrl.setExtension( QLatin1String( "bindname" ),binddn );
|
||||
}
|
||||
mUrl.setFilter( mCfg->ldapgroupfilter() );
|
||||
|
||||
if ( mCfg->ldaptls() ) mUrl.setExtension(QLatin1String( "x-tls" ),QLatin1String( "" ));
|
||||
if ( mCfg->ldapsasl() ) {
|
||||
mUrl.setExtension( QLatin1String( "x-sasl" ), QLatin1String( "" ) );
|
||||
mUrl.setExtension( QLatin1String( "x-mech" ), mCfg->ldapsaslmech() );
|
||||
}
|
||||
|
||||
mUrl.setScope(KLDAP::LdapUrl::One);
|
||||
mUrl.setExtension(QLatin1String( "x-dir" ),QLatin1String( "base" ));
|
||||
|
||||
if ( mCfg->ldaptimelimit() )
|
||||
mUrl.setExtension(QLatin1String( "x-timelimit" ),QString::number(mCfg->ldaptimelimit()));
|
||||
if ( mCfg->ldapsizelimit() )
|
||||
mUrl.setExtension(QLatin1String( "x-sizelimit" ),QString::number(mCfg->ldapsizelimit()));
|
||||
if ( mCfg->ldappagesize() )
|
||||
mUrl.setExtension(QLatin1String( "x-pagesize" ),QString::number(mCfg->ldappagesize()));
|
||||
|
||||
caps = Cap_Passwd;
|
||||
if ( mCfg->ldapsam() ) {
|
||||
caps |= Cap_Samba;
|
||||
domsid = mCfg->samdomsid();
|
||||
}
|
||||
}
|
||||
|
||||
KU_GroupLDAP::~KU_GroupLDAP()
|
||||
{
|
||||
}
|
||||
|
||||
QString KU_GroupLDAP::getRDN( const KU_Group &group ) const
|
||||
{
|
||||
switch ( mCfg->ldapgrouprdn() ) {
|
||||
case KU_PrefsBase::EnumLdapgrouprdn::cn:
|
||||
return QLatin1String( "cn=" ) + group.getName();
|
||||
case KU_PrefsBase::EnumLdapgrouprdn::gidNumber:
|
||||
return QLatin1String( "gidNumber=" ) + QString::number( group.getGID() );
|
||||
default:
|
||||
return QLatin1String( "" );
|
||||
}
|
||||
}
|
||||
|
||||
void KU_GroupLDAP::result( KLDAP::LdapSearch *search )
|
||||
{
|
||||
kDebug() << "LDAP result: " << search->error();
|
||||
mProg->hide();
|
||||
|
||||
if ( search->error() ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(search->error());
|
||||
mOk = false;
|
||||
} else {
|
||||
mOk = true;
|
||||
}
|
||||
}
|
||||
|
||||
void KU_GroupLDAP::data( KLDAP::LdapSearch *, const KLDAP::LdapObject& data )
|
||||
{
|
||||
KU_Group group;
|
||||
|
||||
KLDAP::LdapAttrMap attrs = data.attributes();
|
||||
for ( KLDAP::LdapAttrMap::ConstIterator it = attrs.constBegin(); it != attrs.constEnd(); ++it ) {
|
||||
QString name = it.key().toLower();
|
||||
|
||||
if ( name == QLatin1String( "objectclass" ) ) {
|
||||
for ( KLDAP::LdapAttrValue::ConstIterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2 ) {
|
||||
if ( (*it2).toLower() == "sambagroupmapping" )
|
||||
group.setCaps( KU_Group::Cap_Samba );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( name == QLatin1String( "memberuid" ) ) {
|
||||
for ( KLDAP::LdapAttrValue::ConstIterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2 ) {
|
||||
group.addUser( QLatin1String(*it2) );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
KLDAP::LdapAttrValue values = (*it);
|
||||
if ( values.isEmpty() ) continue;
|
||||
QString val = QString::fromUtf8( values.first(), values.first().size() );
|
||||
if ( name == QLatin1String( "gidnumber" ) )
|
||||
group.setGID( val.toLong() );
|
||||
else if ( name == QLatin1String( "cn" ) )
|
||||
group.setName( val );
|
||||
else if ( name == QLatin1String( "userpassword" ) )
|
||||
group.setPwd( val );
|
||||
else if ( name == QLatin1String( "sambasid" ) )
|
||||
group.setSID( val );
|
||||
else if ( name == QLatin1String( "sambagrouptype" ) )
|
||||
group.setType( val.toInt() );
|
||||
else if ( name == QLatin1String( "displayname" ) )
|
||||
group.setDisplayName( val );
|
||||
else if ( name == QLatin1String( "description" ) )
|
||||
group.setDesc( val );
|
||||
}
|
||||
|
||||
append( group );
|
||||
|
||||
if ( ( count() & 7 ) == 7 ) {
|
||||
mProg->setValue( mProg->value() + mAdv );
|
||||
if ( mProg->value() == 0 ) mAdv = 1;
|
||||
if ( mProg->value() == mProg->maximum()-1 ) mAdv = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool KU_GroupLDAP::reload()
|
||||
{
|
||||
kDebug() << "KU_GroupLDAP::reload()";
|
||||
mErrorString = mErrorDetails = QString();
|
||||
mProg = new QProgressDialog( 0 );
|
||||
mProg->setLabel( new QLabel (i18n("Loading Groups From LDAP")) );
|
||||
mProg->setAutoClose( false );
|
||||
mProg->setMaximum( 100 );
|
||||
mAdv = 1;
|
||||
mOk = true;
|
||||
mProg->show();
|
||||
qApp->processEvents();
|
||||
|
||||
KLDAP::LdapSearch search;
|
||||
connect( &search,
|
||||
SIGNAL(data(KLDAP::LdapSearch*,KLDAP::LdapObject)),
|
||||
this, SLOT (data(KLDAP::LdapSearch*,KLDAP::LdapObject)) );
|
||||
connect( &search,
|
||||
SIGNAL(result(KLDAP::LdapSearch*)),
|
||||
this, SLOT (result(KLDAP::LdapSearch*)) );
|
||||
|
||||
if (search.search( mUrl )) {
|
||||
mProg->exec();
|
||||
if ( mProg->wasCanceled() ) search.abandon();
|
||||
} else {
|
||||
kDebug() << "search failed";
|
||||
mOk = false;
|
||||
mErrorString = KLDAP::LdapConnection::errorString(search.error());
|
||||
mErrorDetails = search.errorString();
|
||||
}
|
||||
delete mProg;
|
||||
return( mOk );
|
||||
}
|
||||
|
||||
bool KU_GroupLDAP::dbcommit()
|
||||
{
|
||||
mAddSucc.clear();
|
||||
mDelSucc.clear();
|
||||
mModSucc.clear();
|
||||
mErrorString = mErrorDetails = QString();
|
||||
KLDAP::LdapConnection conn( mUrl );
|
||||
|
||||
if ( conn.connect() != KLDAP_SUCCESS ) {
|
||||
mErrorString = conn.connectionError();
|
||||
return false;
|
||||
}
|
||||
|
||||
KLDAP::LdapOperation op( conn );
|
||||
|
||||
if ( op.bind_s() != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
return false;
|
||||
}
|
||||
KLDAP::LdapOperation::ModOps ops;
|
||||
|
||||
mProg = new QProgressDialog( 0 );
|
||||
mProg->setLabel( new QLabel(i18n("LDAP Operation")) );
|
||||
mProg->setAutoClose( false );
|
||||
mProg->setAutoReset( false );
|
||||
mProg->setMaximum( mAdd.count() + mMod.count() + mDel.count() );
|
||||
|
||||
//modify
|
||||
for ( KU_Groups::ModList::Iterator it = mMod.begin(); it != mMod.end(); ++it ) {
|
||||
QString oldrdn = getRDN( at( it.key() ) );
|
||||
QString newrdn = getRDN( it.value() );
|
||||
|
||||
if ( oldrdn != newrdn ) {
|
||||
int ret = op.rename_s( KLDAP::LdapDN( oldrdn + QLatin1Char( ',' ) + mUrl.dn().toString() ),
|
||||
newrdn,
|
||||
QLatin1String( mUrl.dn().toString().toUtf8() ),
|
||||
true );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ops.clear();
|
||||
createModStruct( it.value(), it.key(), ops );
|
||||
int ret = op.modify_s( KLDAP::LdapDN( getRDN( it.value() ) + QLatin1Char( ',' ) + mUrl.dn().toString() ), ops );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mModSucc.insert( it.key(), it.value() );
|
||||
}
|
||||
}
|
||||
|
||||
//add
|
||||
for ( KU_Groups::AddList::Iterator it = mAdd.begin(); it != mAdd.end(); ++it ) {
|
||||
ops.clear();
|
||||
createModStruct( (*it), -1, ops );
|
||||
kDebug() << "add name: " << (*it).getName();
|
||||
int ret = op.add_s( KLDAP::LdapDN( getRDN( (*it) ) + QLatin1Char( ',' ) + mUrl.dn().toString() ), ops );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mAddSucc.append( (*it) );
|
||||
}
|
||||
}
|
||||
|
||||
//del
|
||||
for ( KU_Groups::DelList::Iterator it = mDel.begin(); it != mDel.end(); ++it ) {
|
||||
kDebug() << "delete name: " << at((*it)).getName();
|
||||
int ret = op.del_s( KLDAP::LdapDN( getRDN( at((*it)) ) + QLatin1Char( ',' ) + mUrl.dn().toString() ) );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mDelSucc.append( (*it) );
|
||||
}
|
||||
}
|
||||
|
||||
delete mProg;
|
||||
return true;
|
||||
}
|
||||
|
||||
void KU_GroupLDAP::createModStruct( const KU_Group &group, int oldindex, KLDAP::LdapOperation::ModOps &ops)
|
||||
{
|
||||
QList<QByteArray> vals;
|
||||
bool mod = ( oldindex != -1 );
|
||||
|
||||
vals.append("posixgroup");
|
||||
if ( ( getCaps() & Cap_Samba ) && ( group.getCaps() & KU_Group::Cap_Samba ) ) {
|
||||
vals.append("sambagroupmapping");
|
||||
}
|
||||
ku_add2ops( ops, QLatin1String( "objectClass" ), vals );
|
||||
vals.clear();
|
||||
ku_add2ops( ops, QLatin1String( "cn" ), group.getName().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "gidnumber" ), QString::number(group.getGID()).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "userpassword" ), group.getPwd().toUtf8() );
|
||||
for ( uint i=0; i < group.count(); i++ ) {
|
||||
vals.append( group.user(i).toUtf8() );
|
||||
}
|
||||
ku_add2ops( ops, QLatin1String( "memberuid" ), vals );
|
||||
vals.clear();
|
||||
if ( getCaps() & Cap_Samba ) {
|
||||
if ( group.getCaps() & KU_Group::Cap_Samba ) {
|
||||
ku_add2ops( ops, QLatin1String( "sambasid" ), group.getSID().getSID().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "displayname" ), group.getDisplayName().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "description" ), group.getDesc().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambagrouptype" ), QString::number( group.getType() ).toUtf8() );
|
||||
} else if (mod) {
|
||||
ku_add2ops( ops, QLatin1String( "sambasid" ) );
|
||||
ku_add2ops( ops, QLatin1String( "displayname" ) );
|
||||
ku_add2ops( ops, QLatin1String( "description" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambagrouptype" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "ku_groupldap.moc"
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
|
||||
#ifndef _KU_GROUPLDAP_H_
|
||||
#define _KU_GROUPLDAP_H_
|
||||
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <kldap/ldapsearch.h>
|
||||
#include <kldap/ldapobject.h>
|
||||
#include <kldap/ldapoperation.h>
|
||||
#include <kldap/ldapurl.h>
|
||||
#include <kio/job.h>
|
||||
|
||||
#include "ku_group.h"
|
||||
|
||||
class KU_GroupLDAP : public QObject, public KU_Groups {
|
||||
Q_OBJECT
|
||||
public:
|
||||
KU_GroupLDAP( KU_PrefsBase *cfg );
|
||||
virtual ~KU_GroupLDAP();
|
||||
|
||||
virtual bool reload();
|
||||
virtual bool dbcommit();
|
||||
|
||||
private slots:
|
||||
void result( KLDAP::LdapSearch *search );
|
||||
void data( KLDAP::LdapSearch *search, const KLDAP::LdapObject& data );
|
||||
private:
|
||||
KLDAP::LdapUrl mUrl;
|
||||
QProgressDialog *mProg;
|
||||
|
||||
bool mOk;
|
||||
int mAdv;
|
||||
|
||||
QString getRDN( const KU_Group &group ) const;
|
||||
void createModStruct( const KU_Group &group, int oldindex, KLDAP::LdapOperation::ModOps &ops);
|
||||
};
|
||||
|
||||
#endif // _KU_GROUPLDAP_H_
|
|
@ -1,457 +0,0 @@
|
|||
<ui version="4.0" >
|
||||
<class>KU_LdapSamba</class>
|
||||
<widget class="QWidget" name="KU_LdapSamba" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>465</width>
|
||||
<height>281</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Samba</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_ldapsam" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Manage Samba user accounts/groups</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_samloginscript" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="textLabel2_2_2" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Default login script:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samloginscript</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textLabel4_2_2" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Home drive:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samhomedrive</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="textLabel3_2_2" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Profile path template:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samprofilepath</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="textLabel5_2_2" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Home path template:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samhomepath</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_samhomepath" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_samprofilepath" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_samhomedrive" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_lanmanhash" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Store LanManager hashed password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1_2" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Domain name:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samdomain</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="kcfg_samdomain" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KPushButton" name="domQuery" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Query Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Domain SID (you can obtain with 'net getlocalsid domain_name'):</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samdomsid</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="kcfg_samdomsid" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maxLength" >
|
||||
<number>41</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1_3" >
|
||||
<property name="text" >
|
||||
<string>Algorithmic RID base:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_samridbase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="kcfg_samridbase" >
|
||||
<property name="maximum" >
|
||||
<number>65000</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KLineEdit</class>
|
||||
<extends></extends>
|
||||
<header>klineedit.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KPushButton</class>
|
||||
<extends></extends>
|
||||
<header>kpushbutton.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends></extends>
|
||||
<header>knuminput.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>kcfg_ldapsam</tabstop>
|
||||
<tabstop>kcfg_samloginscript</tabstop>
|
||||
<tabstop>kcfg_samprofilepath</tabstop>
|
||||
<tabstop>kcfg_samhomedrive</tabstop>
|
||||
<tabstop>kcfg_samhomepath</tabstop>
|
||||
<tabstop>kcfg_lanmanhash</tabstop>
|
||||
<tabstop>kcfg_samdomain</tabstop>
|
||||
<tabstop>kcfg_samdomsid</tabstop>
|
||||
<tabstop>domQuery</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="global" >knuminput.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samloginscript</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>292</x>
|
||||
<y>47</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samprofilepath</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>292</x>
|
||||
<y>68</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samhomedrive</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>292</x>
|
||||
<y>89</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samhomepath</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>292</x>
|
||||
<y>110</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_lanmanhash</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>232</x>
|
||||
<y>135</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samdomain</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>226</x>
|
||||
<y>166</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>domQuery</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>406</x>
|
||||
<y>166</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samdomsid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>232</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>kcfg_ldapsam</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>kcfg_samridbase</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>232</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>160</x>
|
||||
<y>251</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,271 +0,0 @@
|
|||
<ui version="4.0" >
|
||||
<class>KU_LdapSettings</class>
|
||||
<widget class="QWidget" name="KU_LdapSettings" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>394</width>
|
||||
<height>227</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="1" colspan="3" >
|
||||
<widget class="QLineEdit" name="kcfg_ldapuserfilter" />
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<widget class="KComboBox" name="kcfg_ldapgrouprdn" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>cn</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>gidNumber</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_ldapgroupbase" />
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<widget class="KComboBox" name="kcfg_ldappasswordhash" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Plain Text</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>CRYPT</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>MD5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>SMD5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>SHA</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>SSHA</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="textLabel1" >
|
||||
<property name="text" >
|
||||
<string>User base:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapuserbase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="textLabel1_4_2" >
|
||||
<property name="text" >
|
||||
<string>Group filter:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapgroupfilter</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" >
|
||||
<widget class="QLabel" name="textLabel5" >
|
||||
<property name="text" >
|
||||
<string>Structural objectclass:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapstructural</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="textLabel1_4" >
|
||||
<property name="text" >
|
||||
<string>User filter:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapuserfilter</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="KLineEdit" name="kcfg_ldapuserbase" />
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3" >
|
||||
<widget class="QLineEdit" name="kcfg_ldapgroupfilter" />
|
||||
</item>
|
||||
<item row="4" column="3" >
|
||||
<widget class="KComboBox" name="kcfg_ldapstructural" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>account</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>inetOrgPerson</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" >
|
||||
<widget class="QLabel" name="textLabel3" >
|
||||
<property name="text" >
|
||||
<string>Group RDN prefix:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapgrouprdn</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="KComboBox" name="kcfg_ldapuserrdn" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>uid</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>uidNumber</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>cn</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textLabel1_2" >
|
||||
<property name="text" >
|
||||
<string>Group base:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapgroupbase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QLabel" name="textLabel2" >
|
||||
<property name="text" >
|
||||
<string>User RDN prefix:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldapuserrdn</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="textLabel4" >
|
||||
<property name="text" >
|
||||
<string>Password hash:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>kcfg_ldappasswordhash</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_ldapshadow" >
|
||||
<property name="text" >
|
||||
<string>Manage shadowAccount objectclass</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_ldapcnfullname" >
|
||||
<property name="text" >
|
||||
<string>Store the user's full name in the cn attribute</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_ldapgecos" >
|
||||
<property name="text" >
|
||||
<string>Update the gecos attribute</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcombobox.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KLineEdit</class>
|
||||
<extends></extends>
|
||||
<header>klineedit.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>kcfg_ldapuserbase</tabstop>
|
||||
<tabstop>kcfg_ldapuserrdn</tabstop>
|
||||
<tabstop>kcfg_ldapuserfilter</tabstop>
|
||||
<tabstop>kcfg_ldapgroupbase</tabstop>
|
||||
<tabstop>kcfg_ldapgrouprdn</tabstop>
|
||||
<tabstop>kcfg_ldapgroupfilter</tabstop>
|
||||
<tabstop>kcfg_ldappasswordhash</tabstop>
|
||||
<tabstop>kcfg_ldapstructural</tabstop>
|
||||
<tabstop>kcfg_ldapshadow</tabstop>
|
||||
<tabstop>kcfg_ldapcnfullname</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -253,24 +253,3 @@ time_t daysToTime(int days)
|
|||
{
|
||||
return days*24*60*60;
|
||||
}
|
||||
|
||||
void ku_add2ops( KLDAP::LdapOperation::ModOps &ops, const QString &attr, const QList<QByteArray> &vals, bool allownull )
|
||||
{
|
||||
KLDAP::LdapOperation::ModOp op;
|
||||
op.type = KLDAP::LdapOperation::Mod_Replace;
|
||||
op.attr = attr;
|
||||
for ( int i = 0; i < vals.count(); ++i ) {
|
||||
if ( !vals[i].isEmpty() || allownull ) {
|
||||
op.values.append( vals[i] );
|
||||
}
|
||||
}
|
||||
ops.append( op );
|
||||
}
|
||||
|
||||
void ku_add2ops( KLDAP::LdapOperation::ModOps &ops, const QString &attr, const QByteArray &val, bool allownull )
|
||||
{
|
||||
QList<QByteArray> vals;
|
||||
kDebug() << "add2ops attr: " << attr << " value: '" << val << "'";
|
||||
vals.append( val );
|
||||
ku_add2ops( ops, attr, vals, allownull );
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
#include <QByteArray>
|
||||
|
||||
#include <kldap/ldapoperation.h>
|
||||
|
||||
bool backup(const QString & name);
|
||||
QByteArray genSalt( int len );
|
||||
QString encryptPass( const QString &pass, bool md5 );
|
||||
|
@ -40,7 +38,5 @@ QStringList readShells();
|
|||
void addShell(const QString &shell);
|
||||
int timeToDays(time_t time);
|
||||
time_t daysToTime(int days);
|
||||
void ku_add2ops( KLDAP::LdapOperation::ModOps &ops, const QString &attr, const QList<QByteArray> &vals, bool allownull = false );
|
||||
void ku_add2ops( KLDAP::LdapOperation::ModOps &ops, const QString &attr, const QByteArray &val=QByteArray(), bool allownull = false );
|
||||
|
||||
#endif // _KU_MISC_H_
|
||||
|
|
|
@ -1,583 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QLabel>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kio/kntlm.h>
|
||||
#include <kldap/ldapdefs.h>
|
||||
#include <kldap/ldapdn.h>
|
||||
#include <kldap/ldapconnection.h>
|
||||
#include <kldap/ldapoperation.h>
|
||||
|
||||
#include "ku_userldap.h"
|
||||
#include "ku_misc.h"
|
||||
|
||||
KU_UserLDAP::KU_UserLDAP(KU_PrefsBase *cfg) : KU_Users( cfg )
|
||||
{
|
||||
schemaversion = 0;
|
||||
|
||||
if ( mCfg->ldapssl() )
|
||||
mUrl.setProtocol(QLatin1String( "ldaps" ));
|
||||
else
|
||||
mUrl.setProtocol(QLatin1String( "ldap" ));
|
||||
|
||||
mUrl.setHost( mCfg->ldaphost() );
|
||||
mUrl.setPort( mCfg->ldapport() );
|
||||
mUrl.setDn( KLDAP::LdapDN( mCfg->ldapuserbase() + QLatin1Char( ',' ) + mCfg->ldapdn() ) );
|
||||
if ( !mCfg->ldapanon() ) {
|
||||
mUrl.setUser( mCfg->ldapuser() );
|
||||
mUrl.setPass( mCfg->ldappassword() );
|
||||
QString binddn = mCfg->ldapbinddn();
|
||||
if ( !binddn.isEmpty() )
|
||||
mUrl.setExtension( QLatin1String( "bindname" ),binddn );
|
||||
}
|
||||
mUrl.setFilter( mCfg->ldapuserfilter() );
|
||||
|
||||
if ( mCfg->ldaptls() ) mUrl.setExtension( QLatin1String( "x-tls" ), QLatin1String( "" ) );
|
||||
if ( mCfg->ldapsasl() ) {
|
||||
mUrl.setExtension( QLatin1String( "x-sasl" ), QLatin1String( "" ) );
|
||||
mUrl.setExtension( QLatin1String( "x-mech" ), mCfg->ldapsaslmech() );
|
||||
}
|
||||
|
||||
mUrl.setScope(KLDAP::LdapUrl::One);
|
||||
mUrl.setExtension(QLatin1String( "x-dir" ),QLatin1String( "base" ));
|
||||
|
||||
if ( mCfg->ldaptimelimit() )
|
||||
mUrl.setExtension(QLatin1String( "x-timelimit" ),QString::number(mCfg->ldaptimelimit()));
|
||||
if ( mCfg->ldapsizelimit() )
|
||||
mUrl.setExtension(QLatin1String( "x-sizelimit" ),QString::number(mCfg->ldapsizelimit()));
|
||||
if ( mCfg->ldappagesize() )
|
||||
mUrl.setExtension(QLatin1String( "x-pagesize" ),QString::number(mCfg->ldappagesize()));
|
||||
|
||||
caps = Cap_Passwd | Cap_Disable_POSIX;
|
||||
if ( mCfg->ldapshadow() ) caps |= Cap_Shadow;
|
||||
if ( mCfg->ldapstructural() == KU_PrefsBase::EnumLdapstructural::inetOrgPerson )
|
||||
caps |= Cap_InetOrg;
|
||||
|
||||
if ( mCfg->ldapsam() ) {
|
||||
caps |= Cap_Samba;
|
||||
domsid = mCfg->samdomsid();
|
||||
}
|
||||
}
|
||||
|
||||
KU_UserLDAP::~KU_UserLDAP()
|
||||
{
|
||||
}
|
||||
|
||||
void KU_UserLDAP::result( KLDAP::LdapSearch *search )
|
||||
{
|
||||
kDebug() << "LDAP result: " << search->error() << " " << search->errorString();
|
||||
mProg->hide();
|
||||
|
||||
if ( search->error() ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(search->error());
|
||||
mErrorDetails = search->errorString();
|
||||
mOk = false;
|
||||
} else {
|
||||
mOk = true;
|
||||
}
|
||||
}
|
||||
|
||||
void KU_UserLDAP::data( KLDAP::LdapSearch *, const KLDAP::LdapObject& data )
|
||||
{
|
||||
KU_User user;
|
||||
QStringList objectclasses;
|
||||
|
||||
KLDAP::LdapAttrMap attrs = data.attributes();
|
||||
for ( KLDAP::LdapAttrMap::ConstIterator it = attrs.constBegin(); it != attrs.constEnd(); ++it ) {
|
||||
QString name = it.key().toLower();
|
||||
if ( name == QLatin1String( "objectclass" ) ) {
|
||||
for ( KLDAP::LdapAttrValue::ConstIterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2 ) {
|
||||
if ( (*it2).toLower() == "posixaccount" )
|
||||
user.setCaps( user.getCaps() | KU_User::Cap_POSIX );
|
||||
else if ( (*it2).toLower() == "sambasamaccount" )
|
||||
user.setCaps( user.getCaps() | KU_User::Cap_Samba );
|
||||
else if ( (*it2).toLower() != "inetorgperson" &&
|
||||
(*it2).toLower() != "shadowaccount" &&
|
||||
(*it2).toLower() != "account" )
|
||||
objectclasses.append( QLatin1String( (*it2) ) );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
KLDAP::LdapAttrValue values = (*it);
|
||||
if ( values.isEmpty() ) continue;
|
||||
QString val = QString::fromUtf8( values.first(), values.first().size() );
|
||||
if ( name == QLatin1String( "uidnumber" ) )
|
||||
user.setUID( val.toLong() );
|
||||
else if ( name == QLatin1String( "gidnumber" ) )
|
||||
user.setGID( val.toLong() );
|
||||
else if ( name == QLatin1String( "uid" ) || name == QLatin1String( "userid" ) )
|
||||
user.setName( val );
|
||||
else if ( name == QLatin1String( "sn" ) )
|
||||
user.setSurname( val );
|
||||
else if ( name == QLatin1String( "mail" ) )
|
||||
user.setEmail( val );
|
||||
else if ( name == QLatin1String( "homedirectory" ) )
|
||||
user.setHomeDir( val );
|
||||
else if ( name == QLatin1String( "loginshell" ) )
|
||||
user.setShell( val );
|
||||
else if ( name == QLatin1String( "postaladdress" ) )
|
||||
user.setAddress( val );
|
||||
else if ( name == QLatin1String( "telephonenumber" ) ) {
|
||||
user.setOffice1( val );
|
||||
if ( values.size() > 1 )
|
||||
user.setOffice2( QString::fromUtf8( values[1], values[1].size() ) );
|
||||
} else if ( name == QLatin1String( "gecos" ) ) {
|
||||
QString name, f1, f2, f3;
|
||||
parseGecos( values.first(), name, f1, f2, f3 );
|
||||
if ( user.getFullName().isEmpty() ) user.setFullName( val );
|
||||
if ( user.getOffice1().isEmpty() ) user.setOffice1( f1 );
|
||||
if ( user.getOffice2().isEmpty() ) user.setOffice2( f1 );
|
||||
if ( user.getAddress().isEmpty() ) user.setAddress( f1 );
|
||||
} else if ( name == QLatin1String( "cn" ) ) {
|
||||
if ( user.getFullName().isEmpty() || mCfg->ldapcnfullname() )
|
||||
user.setFullName( val );
|
||||
if ( user.getName().isEmpty() )
|
||||
user.setName( val );
|
||||
} else if ( name == QLatin1String( "displayname" ) ) {
|
||||
user.setFullName( val );
|
||||
} else if ( name == QLatin1String( "userpassword" ) ) {
|
||||
if ( !val.isEmpty() ) user.setDisabled( false );
|
||||
user.setPwd( val );
|
||||
} else if ( name == QLatin1String( "shadowlastchange" ) ) {
|
||||
if ( user.getLastChange() == 0 ) //sambapwdlastset is more precise
|
||||
user.setLastChange( daysToTime( val.toLong() ) );
|
||||
} else if ( name == QLatin1String( "shadowmin" ) )
|
||||
user.setMin( val.toInt() );
|
||||
else if ( name == QLatin1String( "shadowmax" ) )
|
||||
user.setMax( val.toLong() );
|
||||
else if ( name == QLatin1String( "shadowwarning" ) )
|
||||
user.setWarn( val.toLong() );
|
||||
else if ( name == QLatin1String( "shadowinactive" ) )
|
||||
user.setInactive( val.toLong() );
|
||||
else if ( name == QLatin1String( "shadowexpire" ) )
|
||||
user.setExpire( val.toLong() );
|
||||
else if ( name == QLatin1String( "shadowflag" ) )
|
||||
user.setFlag( val.toLong() );
|
||||
else if ( name == QLatin1String( "sambaacctflags" ) ) {
|
||||
if ( !val.contains( QLatin1Char( 'D' ) ) ) user.setDisabled( false );
|
||||
} else if ( name == QLatin1String( "sambasid" ) )
|
||||
user.setSID( val );
|
||||
else if ( name == QLatin1String( "sambaprimarygroupsid" ) )
|
||||
user.setPGSID( val );
|
||||
else if ( name == QLatin1String( "sambalmpassword" ) )
|
||||
user.setLMPwd( val );
|
||||
else if ( name == QLatin1String( "sambantpassword" ) )
|
||||
user.setNTPwd( val );
|
||||
else if ( name == QLatin1String( "sambahomepath" ) )
|
||||
user.setHomePath( val );
|
||||
else if ( name == QLatin1String( "sambahomedrive" ) )
|
||||
user.setHomeDrive( val );
|
||||
else if ( name == QLatin1String( "sambalogonscript" ) )
|
||||
user.setLoginScript( val );
|
||||
else if ( name == QLatin1String( "sambaprofilepath" ) )
|
||||
user.setProfilePath( val );
|
||||
else if ( name == QLatin1String( "sambauserworkstations" ) )
|
||||
user.setWorkstations( val );
|
||||
else if ( name == QLatin1String( "sambadomainname" ) )
|
||||
user.setDomain( val );
|
||||
else if ( name == QLatin1String( "sambapwdlastset" ) )
|
||||
user.setLastChange( val.toLong() );
|
||||
//these new attributes introduced around samba 3.0.6
|
||||
else if ( name == QLatin1String( "sambapasswordhistory" ) || name == QLatin1String( "sambalogonhours" ) )
|
||||
schemaversion = 1;
|
||||
|
||||
}
|
||||
|
||||
kDebug() << "new user: " << user.getName();
|
||||
if ( !objectclasses.isEmpty() ) {
|
||||
mObjectClasses.insert( count(), objectclasses );
|
||||
kDebug() << "user: " << user.getName() << " other objectclasses: " << objectclasses.join(QLatin1String( "," ));
|
||||
}
|
||||
append( user );
|
||||
|
||||
if ( ( count() & 7 ) == 7 ) {
|
||||
mProg->setValue( mProg->value() + mAdv );
|
||||
if ( mProg->value() == 0 ) mAdv = 1;
|
||||
if ( mProg->value() == mProg->maximum()-1 ) mAdv = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool KU_UserLDAP::reload()
|
||||
{
|
||||
kDebug() << "KU_UserLDAP::reload()";
|
||||
mErrorString = mErrorDetails = QString();
|
||||
mObjectClasses.clear();
|
||||
mProg = new QProgressDialog( 0 );
|
||||
mProg->setLabel( new QLabel( i18n("Loading Users From LDAP") ) );
|
||||
mProg->setAutoClose( false );
|
||||
mProg->setAutoReset( false );
|
||||
mProg->setMaximum( 100 );
|
||||
mAdv = 1;
|
||||
mOk = true;
|
||||
mProg->show();
|
||||
qApp->processEvents();
|
||||
KLDAP::LdapSearch search;
|
||||
|
||||
connect( &search,
|
||||
SIGNAL(data(KLDAP::LdapSearch*,KLDAP::LdapObject)),
|
||||
this, SLOT (data(KLDAP::LdapSearch*,KLDAP::LdapObject)) );
|
||||
connect( &search,
|
||||
SIGNAL(result(KLDAP::LdapSearch*)),
|
||||
this, SLOT (result(KLDAP::LdapSearch*)) );
|
||||
|
||||
if (search.search( mUrl )) {
|
||||
mProg->exec();
|
||||
if ( mProg->wasCanceled() ) search.abandon();
|
||||
} else {
|
||||
kDebug() << "search failed";
|
||||
mOk = false;
|
||||
mErrorString = KLDAP::LdapConnection::errorString(search.error());
|
||||
mErrorDetails = search.errorString();
|
||||
}
|
||||
delete mProg;
|
||||
return( mOk );
|
||||
}
|
||||
|
||||
QString KU_UserLDAP::getRDN(const KU_User &user) const
|
||||
{
|
||||
switch ( mCfg->ldapuserrdn() ) {
|
||||
case KU_PrefsBase::EnumLdapuserrdn::uid:
|
||||
return QLatin1String( "uid=" ) + user.getName();
|
||||
case KU_PrefsBase::EnumLdapuserrdn::uidNumber:
|
||||
return QLatin1String( "uidNumber=" ) + QString::number( user.getUID() );
|
||||
case KU_PrefsBase::EnumLdapuserrdn::cn: {
|
||||
QString cn = mCfg->ldapcnfullname() ? user.getFullName() : user.getName();
|
||||
if ( cn.isEmpty() ) cn = user.getName();
|
||||
return QLatin1String( "cn=" ) + cn;
|
||||
}
|
||||
}
|
||||
return QLatin1String( "" );
|
||||
}
|
||||
|
||||
void KU_UserLDAP::createPassword( KU_User &user, const QString &password )
|
||||
{
|
||||
switch ( mCfg->ldappasswordhash() ) {
|
||||
case KU_PrefsBase::EnumLdappasswordhash::Clear:
|
||||
user.setPwd( password );
|
||||
break;
|
||||
case KU_PrefsBase::EnumLdappasswordhash::CRYPT:
|
||||
user.setPwd( QLatin1String( "{CRYPT}" ) + encryptPass( password, false ) );
|
||||
break;
|
||||
case KU_PrefsBase::EnumLdappasswordhash::MD5: {
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
md5.addData( password.toUtf8() );
|
||||
user.setPwd( QLatin1String( "{MD5}" ) + QLatin1String( md5.result().toBase64() ) );
|
||||
break;
|
||||
}
|
||||
case KU_PrefsBase::EnumLdappasswordhash::SMD5: {
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
QByteArray salt = genSalt( 8 );
|
||||
QByteArray pwd = password.toUtf8() + salt;
|
||||
|
||||
md5.addData( pwd );
|
||||
user.setPwd( QLatin1String( "{SMD5}" ) + QLatin1String( (md5.result() + salt).toBase64() ) );
|
||||
break;
|
||||
}
|
||||
case KU_PrefsBase::EnumLdappasswordhash::SHA: {
|
||||
QCryptographicHash sha1(QCryptographicHash::Sha1);
|
||||
|
||||
sha1.addData( password.toUtf8() );
|
||||
user.setPwd( QLatin1String( "{SHA}" ) + QLatin1String( sha1.result().toBase64() ) );
|
||||
break;
|
||||
}
|
||||
case KU_PrefsBase::EnumLdappasswordhash::SSHA: {
|
||||
QCryptographicHash sha1(QCryptographicHash::Sha1);
|
||||
|
||||
QByteArray salt = genSalt( 8 );
|
||||
QByteArray pwd = password.toUtf8() + salt;
|
||||
|
||||
sha1.addData( pwd );
|
||||
user.setPwd( QLatin1String( "{SSHA}" ) + QLatin1String( (sha1.result() + salt).toBase64() ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( caps & Cap_Samba ) {
|
||||
quint8 hex[33];
|
||||
|
||||
QByteArray ntlmhash;
|
||||
ntlmhash = KNTLM::ntlmHash( password );
|
||||
unsigned char *hash = (unsigned char*) ntlmhash.data();
|
||||
|
||||
snprintf( (char*) &hex, 33,
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5],
|
||||
hash[6], hash[7], hash[8], hash[9], hash[10], hash[11],
|
||||
hash[12], hash[13], hash[14], hash[15]);
|
||||
|
||||
user.setNTPwd( QString::fromLatin1( (const char*) &hex, 32 ) );
|
||||
|
||||
if ( mCfg->lanmanhash() ) {
|
||||
|
||||
QByteArray lmhash;
|
||||
lmhash = KNTLM::lmHash( password );
|
||||
unsigned char *hash = (unsigned char*) lmhash.data();
|
||||
snprintf( (char*) &hex, 33,
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5],
|
||||
hash[6], hash[7], hash[8], hash[9], hash[10], hash[11],
|
||||
hash[12], hash[13], hash[14], hash[15]);
|
||||
|
||||
user.setLMPwd( QString::fromLatin1( (const char*) &hex, 32 ) );
|
||||
} else {
|
||||
user.setLMPwd( QLatin1String( "" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KU_UserLDAP::createModStruct( const KU_User &user, int oldindex, KLDAP::LdapOperation::ModOps &ops)
|
||||
{
|
||||
QString gecos, cn, pwd, samflags;
|
||||
QList<QByteArray> vals;
|
||||
|
||||
bool mod = ( oldindex != -1 );
|
||||
|
||||
pwd = user.getPwd();
|
||||
if ( user.getDisabled() ) pwd = QLatin1String( "" );
|
||||
|
||||
cn = mCfg->ldapcnfullname() ? user.getFullName() : user.getName();
|
||||
if ( cn.isEmpty() ) cn = user.getName();
|
||||
|
||||
gecos = QString::fromLatin1("%1,%2,%3,%4")
|
||||
.arg(user.getFullName())
|
||||
.arg(user.getOffice1())
|
||||
.arg(user.getOffice2())
|
||||
.arg(user.getAddress());
|
||||
|
||||
samflags = QLatin1String( "[U" );
|
||||
samflags += user.getDisabled() ? QLatin1Char( 'D' ) : QLatin1Char( ' ' );
|
||||
samflags += QLatin1String( " ]" );
|
||||
|
||||
vals.append( caps & Cap_InetOrg ? "inetOrgPerson" : "account" );
|
||||
if ( user.getCaps() & KU_User::Cap_POSIX ) {
|
||||
vals.append( "posixAccount" );
|
||||
}
|
||||
if ( ( caps & Cap_Shadow ) && ( user.getCaps() & KU_User::Cap_POSIX ) ) {
|
||||
vals.append( "shadowAccount" );
|
||||
}
|
||||
if ( ( caps & Cap_Samba ) && ( user.getCaps() & KU_User::Cap_Samba ) ) {
|
||||
vals.append( "sambaSamAccount" );
|
||||
}
|
||||
|
||||
if ( mod && mObjectClasses.contains( oldindex ) ) {
|
||||
QStringList ocs = mObjectClasses[ oldindex ];
|
||||
kDebug() << user.getName() << " has additional objectclasses: " << ocs.join(QLatin1String( "," ));
|
||||
QStringList::iterator it;
|
||||
for ( it = ocs.begin(); it != ocs.end(); ++it ) {
|
||||
vals.append( (*it).toUtf8() );
|
||||
}
|
||||
}
|
||||
ku_add2ops( ops, QLatin1String( "objectClass" ), vals );
|
||||
vals.clear();
|
||||
|
||||
ku_add2ops( ops, QLatin1String( "cn" ), cn.toUtf8() );
|
||||
ku_add2ops( ops, caps & Cap_InetOrg ? QLatin1String( "uid" ) : QLatin1String( "userid" ), user.getName().toUtf8() );
|
||||
|
||||
if ( ( user.getCaps() & KU_User::Cap_POSIX ) || ( caps & Cap_InetOrg ) ) {
|
||||
ku_add2ops( ops, QLatin1String( "userpassword" ), pwd.toUtf8(), true );
|
||||
}
|
||||
|
||||
if ( user.getCaps() & KU_User::Cap_POSIX ) {
|
||||
ku_add2ops( ops, QLatin1String( "uidnumber" ), QString::number(user.getUID()).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "gidnumber" ), QString::number(user.getGID()).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "gecos" ), !mCfg->ldapgecos() ? QByteArray() : QByteArray( gecos.toLatin1() ) );
|
||||
ku_add2ops( ops, QLatin1String( "homedirectory" ), user.getHomeDir().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "loginshell" ), user.getShell().toUtf8() );
|
||||
} else if (mod) {
|
||||
ku_add2ops( ops, QLatin1String( "uidnumber" ) );
|
||||
ku_add2ops( ops, QLatin1String( "gidnumber" ) );
|
||||
ku_add2ops( ops, QLatin1String( "gecos" ) );
|
||||
ku_add2ops( ops, QLatin1String( "homedirectory" ) );
|
||||
ku_add2ops( ops, QLatin1String( "loginshell" ) );
|
||||
}
|
||||
|
||||
if ( caps & Cap_InetOrg ) {
|
||||
ku_add2ops( ops, QLatin1String( "sn" ), user.getSurname().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "mail" ), user.getEmail().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "displayName" ), user.getFullName().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "postaladdress" ), user.getAddress().toUtf8() );
|
||||
vals.append( user.getOffice1().toUtf8() );
|
||||
vals.append( user.getOffice2().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "telephoneNumber" ), vals );
|
||||
vals.clear();
|
||||
}
|
||||
|
||||
if ( caps & Cap_Samba ) {
|
||||
if ( user.getCaps() & KU_User::Cap_Samba ) {
|
||||
ku_add2ops( ops, QLatin1String( "sambadomainname" ), user.getDomain().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambauserworkstations" ), user.getWorkstations().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambahomepath" ), user.getHomePath().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambahomedrive" ), user.getHomeDrive().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambalogonscript" ), user.getLoginScript().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambaprofilepath" ), user.getProfilePath().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambalmpassword" ), user.getLMPwd().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambantpassword" ), user.getNTPwd().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambasid" ), user.getSID().getSID().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambaacctflags" ), samflags.toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambaprimarygroupsid" ), user.getPGSID().getSID().toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambapwdlastset" ), QString::number( user.getLastChange() ).toUtf8() );
|
||||
if ( user.getExpire() != -1 )
|
||||
vals.append( QString::number( user.getExpire() ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "sambakickofftime" ), vals );
|
||||
vals.clear();
|
||||
} else if (mod) {
|
||||
ku_add2ops( ops, QLatin1String( "sambadomainname" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambauserworkstations" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambahomepath" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambahomedrive" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambalogonscript" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambaprofilepath" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambalmpassword" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambantpassword" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambasid" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambaacctflags" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambaprimarygroupsid" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambapwdlastset" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambakickofftime" ) );
|
||||
if ( schemaversion > 0 ) {
|
||||
ku_add2ops( ops, QLatin1String( "sambapasswordhistory" ) );
|
||||
ku_add2ops( ops, QLatin1String( "sambalogonhours" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( caps & Cap_Shadow ) {
|
||||
if ( user.getCaps() & KU_User::Cap_POSIX ) {
|
||||
ku_add2ops( ops, QLatin1String( "shadowlastchange" ), QString::number( timeToDays( user.getLastChange() ) ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowmin" ), QString::number( user.getMin() ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowmax" ), QString::number( user.getMax() ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowwarning" ), QString::number( user.getWarn() ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowinactive" ), QString::number( user.getInactive() ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowexpire" ), QString::number( timeToDays( user.getExpire() ) ).toUtf8() );
|
||||
ku_add2ops( ops, QLatin1String( "shadowflag" ), QString::number( user.getFlag() ).toUtf8() );
|
||||
} else if (mod) {
|
||||
ku_add2ops( ops, QLatin1String( "shadowlastchange" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowmin" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowmax" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowwarning" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowinactive" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowexpire" ) );
|
||||
ku_add2ops( ops, QLatin1String( "shadowflag" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KU_UserLDAP::dbcommit()
|
||||
{
|
||||
mAddSucc.clear();
|
||||
mDelSucc.clear();
|
||||
mModSucc.clear();
|
||||
mErrorString = mErrorDetails = QString();
|
||||
|
||||
KLDAP::LdapConnection conn( mUrl );
|
||||
|
||||
if ( conn.connect() != KLDAP_SUCCESS ) {
|
||||
mErrorString = conn.connectionError();
|
||||
return false;
|
||||
}
|
||||
|
||||
KLDAP::LdapOperation op( conn );
|
||||
|
||||
if ( op.bind_s() != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
KLDAP::LdapOperation::ModOps ops;
|
||||
|
||||
mProg = new QProgressDialog( 0 );
|
||||
mProg->setLabel( new QLabel(i18n("LDAP Operation") ) );
|
||||
mProg->setAutoClose( false );
|
||||
mProg->setAutoReset( false );
|
||||
mProg->setMaximum( mAdd.count() + mDel.count() + mMod.count() );
|
||||
|
||||
//modify
|
||||
for ( KU_Users::ModList::Iterator it = mMod.begin(); it != mMod.end(); ++it ) {
|
||||
QString oldrdn = getRDN( at( it.key() ) );
|
||||
QString newrdn = getRDN( it.value() );
|
||||
|
||||
if ( oldrdn != newrdn ) {
|
||||
int ret = op.rename_s( KLDAP::LdapDN( oldrdn + QLatin1Char( ',' ) + mUrl.dn().toString() ),
|
||||
newrdn,
|
||||
QLatin1String( mUrl.dn().toString().toUtf8() ),
|
||||
true );
|
||||
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ops.clear();
|
||||
createModStruct( it.value(), it.key(), ops );
|
||||
int ret = op.modify_s( KLDAP::LdapDN( getRDN( it.value() ) + QLatin1Char( ',' ) + mUrl.dn().toString() ), ops );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mModSucc.insert( it.key(), it.value() );
|
||||
}
|
||||
}
|
||||
|
||||
//add
|
||||
for ( KU_Users::AddList::Iterator it = mAdd.begin(); it != mAdd.end(); ++it ) {
|
||||
ops.clear();
|
||||
createModStruct( (*it), -1, ops );
|
||||
kDebug() << "add name: " << (*it).getName();
|
||||
int ret = op.add_s( KLDAP::LdapDN( getRDN( (*it) ) + QLatin1Char( ',' ) + mUrl.dn().toString() ), ops );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mAddSucc.append( (*it) );
|
||||
}
|
||||
}
|
||||
|
||||
//del
|
||||
for ( KU_Users::DelList::Iterator it = mDel.begin(); it != mDel.end(); ++it ) {
|
||||
kDebug() << "delete name: " << at((*it)).getName();
|
||||
int ret = op.del_s( KLDAP::LdapDN( getRDN( at((*it)) ) + QLatin1Char( ',' ) + mUrl.dn().toString() ) );
|
||||
if ( ret != KLDAP_SUCCESS ) {
|
||||
mErrorString = KLDAP::LdapConnection::errorString(conn.ldapErrorCode());
|
||||
mErrorDetails = conn.ldapErrorString();
|
||||
delete mProg;
|
||||
return false;
|
||||
} else {
|
||||
mDelSucc.append( (*it) );
|
||||
}
|
||||
}
|
||||
|
||||
delete mProg;
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "ku_userldap.moc"
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
|
||||
#ifndef _KU_USERLDAP_H_
|
||||
#define _KU_USERLDAP_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <kldap/ldapurl.h>
|
||||
#include <kldap/ldif.h>
|
||||
#include <kldap/ldapsearch.h>
|
||||
#include <kldap/ldapobject.h>
|
||||
#include <kldap/ldapoperation.h>
|
||||
|
||||
#include <kio/job.h>
|
||||
|
||||
#include "ku_user.h"
|
||||
|
||||
class KU_UserLDAP : public QObject, public KU_Users {
|
||||
Q_OBJECT
|
||||
public:
|
||||
KU_UserLDAP(KU_PrefsBase *cfg);
|
||||
virtual ~KU_UserLDAP();
|
||||
|
||||
virtual bool reload();
|
||||
virtual bool dbcommit();
|
||||
|
||||
private slots:
|
||||
void result( KLDAP::LdapSearch *search );
|
||||
void data( KLDAP::LdapSearch *search, const KLDAP::LdapObject& data );
|
||||
private:
|
||||
KLDAP::LdapUrl mUrl;
|
||||
QProgressDialog *mProg;
|
||||
bool mOk;
|
||||
int mAdv;
|
||||
int schemaversion;
|
||||
QMap<int, QStringList> mObjectClasses;
|
||||
|
||||
QString getRDN( const KU_User &user ) const;
|
||||
void createModStruct( const KU_User &user, int oldindex, KLDAP::LdapOperation::ModOps &ops);
|
||||
|
||||
virtual void createPassword( KU_User &user, const QString &password );
|
||||
};
|
||||
|
||||
#endif // _KU_USERLDAP_H_
|
Loading…
Add table
Reference in a new issue