• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.13.3 API Reference
  • KDE Home
  • Contact Us
 

KLDAP Library

  • kldap
ldapconfigwidget.cpp
1 /*
2  This file is part of libkldap.
3  Copyright (c) 2004-2006 Szombathelyi György <gyurco@freemail.hu>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "ldapconfigwidget.h"
22 #include "ldapsearch.h"
23 
24 #include <kprogressdialog.h>
25 #include <kcombobox.h>
26 #include <kdebug.h>
27 #include <klocalizedstring.h>
28 #include <klineedit.h>
29 #include <kmessagebox.h>
30 
31 #include <QtCore/QObject>
32 #include <QCheckBox>
33 #include <QGroupBox>
34 #include <QLabel>
35 #include <QLayout>
36 #include <QPushButton>
37 #include <QRadioButton>
38 #include <QSpinBox>
39 
40 using namespace KLDAP;
41 
42 class LdapConfigWidget::Private
43 {
44  public:
45  Private( LdapConfigWidget *parent )
46  : mParent( parent ), mFeatures( W_ALL ), mProg( 0 )
47  {
48  mainLayout = new QGridLayout( mParent );
49  mainLayout->setMargin( 0 );
50  }
51 
52  void setLDAPPort();
53  void setLDAPSPort();
54  void setAnonymous( bool on );
55  void setSimple( bool on );
56  void setSASL( bool on );
57  void queryDNClicked();
58  void queryMechClicked();
59  void loadData( LdapSearch *search, const LdapObject &object );
60  void loadResult( LdapSearch *search );
61  void sendQuery();
62  void initWidget();
63 
64  LdapConfigWidget *mParent;
65  WinFlags mFeatures;
66  QStringList mQResult;
67  QString mAttr;
68 
69  KLineEdit *mUser;
70  KLineEdit *mPassword;
71  KLineEdit *mHost;
72  QSpinBox *mPort, *mVersion, *mSizeLimit, *mTimeLimit, *mPageSize;
73  KLineEdit *mDn, *mBindDn, *mRealm;
74  KLineEdit *mFilter;
75  QRadioButton *mAnonymous,*mSimple,*mSASL;
76  QCheckBox *mSubTree;
77  QPushButton *mEditButton;
78  QPushButton *mQueryMech;
79  QRadioButton *mSecNo,*mSecTLS,*mSecSSL;
80  KComboBox *mMech;
81 
82  bool mCancelled;
83  KProgressDialog *mProg;
84 
85  QGridLayout *mainLayout;
86 };
87 
88 void LdapConfigWidget::Private::initWidget()
89 {
90  QLabel *label;
91 
92  mUser = mPassword = mHost = mDn = mBindDn = mRealm = mFilter = 0;
93  mPort = mVersion = mTimeLimit = mSizeLimit = 0;
94  mAnonymous = mSimple = mSASL = mSecNo = mSecTLS = mSecSSL = 0;
95  mEditButton = mQueryMech = 0;
96  mPageSize = 0;
97  mMech = 0;
98  int row = 0;
99  int col;
100 
101  if ( mFeatures & W_USER ) {
102  label = new QLabel( i18n( "User:" ), mParent );
103  mUser = new KLineEdit( mParent );
104  mUser->setObjectName( QLatin1String("kcfg_ldapuser") );
105 
106  mainLayout->addWidget( label, row, 0 );
107  mainLayout->addWidget( mUser, row, 1, 1, 3 );
108  row++;
109  }
110 
111  if ( mFeatures & W_BINDDN ) {
112  label = new QLabel( i18n( "Bind DN:" ), mParent );
113  mBindDn = new KLineEdit( mParent );
114  mBindDn->setObjectName( QLatin1String("kcfg_ldapbinddn") );
115 
116  mainLayout->addWidget( label, row, 0 );
117  mainLayout->addWidget( mBindDn, row, 1, 1, 3 );
118  row++;
119  }
120 
121  if ( mFeatures & W_REALM ) {
122  label = new QLabel( i18n( "Realm:" ), mParent );
123  mRealm = new KLineEdit( mParent );
124  mRealm->setObjectName( QLatin1String("kcfg_ldaprealm") );
125 
126  mainLayout->addWidget( label, row, 0 );
127  mainLayout->addWidget( mRealm, row, 1, 1, 3 );
128  row++;
129  }
130 
131  if ( mFeatures & W_PASS ) {
132  label = new QLabel( i18n( "Password:" ), mParent );
133  mPassword = new KLineEdit( mParent );
134  mPassword->setObjectName( QLatin1String("kcfg_ldappassword") );
135  mPassword->setEchoMode( KLineEdit::Password );
136 
137  mainLayout->addWidget( label, row, 0 );
138  mainLayout->addWidget( mPassword, row, 1, 1, 3 );
139  row++;
140  }
141 
142  if ( mFeatures & W_HOST ) {
143  label = new QLabel( i18n( "Host:" ), mParent );
144  mHost = new KLineEdit( mParent );
145  mHost->setObjectName( QLatin1String("kcfg_ldaphost") );
146  mParent->connect(mHost, SIGNAL(textChanged(QString)), SIGNAL(hostNameChanged(QString)));
147  mainLayout->addWidget( label, row, 0 );
148  mainLayout->addWidget( mHost, row, 1, 1, 3 );
149  row++;
150  }
151 
152  col = 0;
153  if ( mFeatures & W_PORT ) {
154  label = new QLabel( i18n( "Port:" ), mParent );
155  mPort = new QSpinBox( mParent );
156  mPort->setRange( 0, 65535 );
157  mPort->setObjectName( QLatin1String("kcfg_ldapport") );
158  mPort->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
159  mPort->setValue( 389 );
160 
161  mainLayout->addWidget( label, row, col );
162  mainLayout->addWidget( mPort, row, col+1 );
163  col += 2;
164  }
165 
166  if ( mFeatures & W_VER ) {
167  label = new QLabel( i18n( "LDAP version:" ), mParent );
168  mVersion = new QSpinBox( mParent );
169  mVersion->setRange( 2, 3 );
170  mVersion->setObjectName( QLatin1String("kcfg_ldapver") );
171  mVersion->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
172  mVersion->setValue( 3 );
173  mainLayout->addWidget( label, row, col );
174  mainLayout->addWidget( mVersion, row, col+1 );
175  }
176  if ( mFeatures & ( W_PORT | W_VER ) ) {
177  row++;
178  }
179 
180  col = 0;
181  if ( mFeatures & W_SIZELIMIT ) {
182  label = new QLabel( i18n( "Size limit:" ), mParent );
183  mSizeLimit = new QSpinBox( mParent );
184  mSizeLimit->setRange( 0, 9999999 );
185  mSizeLimit->setObjectName( QLatin1String("kcfg_ldapsizelimit") );
186  mSizeLimit->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
187  mSizeLimit->setValue( 0 );
188  mSizeLimit->setSpecialValueText( i18nc( "default ldap size limit", "Default" ) );
189  mainLayout->addWidget( label, row, col );
190  mainLayout->addWidget( mSizeLimit, row, col+1 );
191  col += 2;
192  }
193 
194  if ( mFeatures & W_TIMELIMIT ) {
195  label = new QLabel( i18n( "Time limit:" ), mParent );
196  mTimeLimit = new QSpinBox( mParent );
197  mTimeLimit->setRange( 0, 9999999 );
198  mTimeLimit->setObjectName( QLatin1String("kcfg_ldaptimelimit") );
199  mTimeLimit->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
200  mTimeLimit->setValue( 0 );
201  mTimeLimit->setSuffix( i18n( " sec" ) );
202  mTimeLimit->setSpecialValueText( i18nc( "default ldap time limit", "Default" ) );
203  mainLayout->addWidget( label, row, col );
204  mainLayout->addWidget( mTimeLimit, row, col+1 );
205  }
206  if ( mFeatures & ( W_SIZELIMIT | W_TIMELIMIT ) ) {
207  row++;
208  }
209 
210  if ( mFeatures & W_PAGESIZE ) {
211  label = new QLabel( i18n( "Page size:" ), mParent );
212  mPageSize = new QSpinBox( mParent );
213  mPageSize->setRange( 0, 9999999 );
214  mPageSize->setObjectName( QLatin1String("kcfg_ldappagesize") );
215  mPageSize->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
216  mPageSize->setValue( 0 );
217  mPageSize->setSpecialValueText( i18n( "No paging" ) );
218  mainLayout->addWidget( label, row, 0 );
219  mainLayout->addWidget( mPageSize, row++, 1 );
220  }
221 
222  if ( mFeatures & W_DN ) {
223  label = new QLabel( i18nc( "Distinguished Name", "DN:" ), mParent );
224  mDn = new KLineEdit( mParent );
225  mDn->setObjectName( QLatin1String("kcfg_ldapdn") );
226 
227  mainLayout->addWidget( label, row, 0 );
228  mainLayout->addWidget( mDn, row, 1, 1, 1 );
229  //without host query doesn't make sense
230  if ( mHost ) {
231  QPushButton *dnquery = new QPushButton( i18n( "Query Server" ), mParent );
232  connect( dnquery, SIGNAL(clicked()), mParent, SLOT(queryDNClicked()) );
233  mainLayout->addWidget( dnquery, row, 2, 1, 1 );
234  }
235  row++;
236  }
237 
238  if ( mFeatures & W_FILTER ) {
239  label = new QLabel( i18n( "Filter:" ), mParent );
240  mFilter = new KLineEdit( mParent );
241  mFilter->setObjectName( QLatin1String("kcfg_ldapfilter") );
242 
243  mainLayout->addWidget( label, row, 0 );
244  mainLayout->addWidget( mFilter, row, 1, 1, 3 );
245  row++;
246  }
247 
248  if ( mFeatures & W_SECBOX ) {
249  QGroupBox *btgroup = new QGroupBox( i18n( "Security" ), mParent );
250  QHBoxLayout *hbox = new QHBoxLayout;
251  btgroup->setLayout( hbox );
252  mSecNo = new QRadioButton( i18nc( "@option:radio set no security", "No" ), btgroup );
253  mSecNo->setObjectName( QLatin1String("kcfg_ldapnosec") );
254  hbox->addWidget( mSecNo );
255  mSecTLS = new QRadioButton( i18nc( "@option:radio use TLS security", "TLS" ), btgroup );
256  mSecTLS->setObjectName( QLatin1String("kcfg_ldaptls") );
257  hbox->addWidget( mSecTLS );
258  mSecSSL = new QRadioButton( i18nc( "@option:radio use SSL security", "SSL" ), btgroup );
259  mSecSSL->setObjectName( QLatin1String("kcfg_ldapssl") );
260  hbox->addWidget( mSecSSL );
261  mainLayout->addWidget( btgroup, row, 0, 1, 4 );
262 
263  connect( mSecNo, SIGNAL(clicked()), mParent, SLOT(setLDAPPort()) );
264  connect( mSecTLS, SIGNAL(clicked()), mParent, SLOT(setLDAPPort()) );
265  connect( mSecSSL, SIGNAL(clicked()), mParent, SLOT(setLDAPSPort()) );
266 
267  mSecNo->setChecked( true );
268  row++;
269  }
270 
271  if ( mFeatures & W_AUTHBOX ) {
272 
273  QGroupBox *authbox =
274  new QGroupBox( i18n( "Authentication" ), mParent );
275  QVBoxLayout *vbox = new QVBoxLayout;
276  authbox->setLayout( vbox );
277  QHBoxLayout *hbox = new QHBoxLayout;
278  vbox->addLayout( hbox );
279 
280  mAnonymous =
281  new QRadioButton( i18nc( "@option:radio anonymous authentication", "Anonymous" ), authbox );
282  mAnonymous->setObjectName( QLatin1String("kcfg_ldapanon") );
283  hbox->addWidget( mAnonymous );
284  mSimple =
285  new QRadioButton( i18nc( "@option:radio simple authentication", "Simple" ), authbox );
286  mSimple->setObjectName( QLatin1String("kcfg_ldapsimple") );
287  hbox->addWidget( mSimple );
288  mSASL =
289  new QRadioButton( i18nc( "@option:radio SASL authentication", "SASL" ), authbox );
290  mSASL->setObjectName( QLatin1String("kcfg_ldapsasl") );
291  hbox->addWidget( mSASL );
292 
293  hbox = new QHBoxLayout;
294  vbox->addLayout( hbox );
295  label = new QLabel( i18n( "SASL mechanism:" ), authbox );
296  hbox->addWidget( label );
297  mMech = new KComboBox( false, authbox );
298  mMech->setObjectName( QLatin1String("kcfg_ldapsaslmech") );
299  mMech->setEditable( true );
300  mMech->addItem( QLatin1String("DIGEST-MD5") );
301  mMech->addItem( QLatin1String("GSSAPI") );
302  mMech->addItem( QLatin1String("PLAIN") );
303  hbox->addWidget( mMech );
304 
305  //without host query doesn't make sense
306  if ( mHost ) {
307  mQueryMech = new QPushButton( i18n( "Query Server" ), authbox );
308  hbox->addWidget( mQueryMech );
309  connect( mQueryMech, SIGNAL(clicked()), mParent, SLOT(queryMechClicked()) );
310  }
311 
312  mainLayout->addWidget( authbox, row, 0, 2, 4 );
313 
314  connect( mAnonymous, SIGNAL(toggled(bool)), mParent, SLOT(setAnonymous(bool)) );
315  connect( mSimple, SIGNAL(toggled(bool)), mParent, SLOT(setSimple(bool)) );
316  connect( mSASL, SIGNAL(toggled(bool)), mParent, SLOT(setSASL(bool)) );
317 
318  mAnonymous->setChecked( true );
319  }
320 }
321 
322 void LdapConfigWidget::Private::sendQuery()
323 {
324  LdapServer _server( mParent->server() );
325 
326  mQResult.clear();
327  mCancelled = true;
328 
329  if ( mAttr == QLatin1String("supportedsaslmechanisms") ) {
330  _server.setAuth( LdapServer::Anonymous );
331  }
332 
333  LdapUrl _url( _server.url() );
334 
335  _url.setDn( LdapDN( QLatin1String("") ) );
336  _url.setAttributes( QStringList( mAttr ) );
337  _url.setScope( LdapUrl::Base );
338 
339  kDebug() << "sendQuery url:" << _url.prettyUrl();
340 
341  LdapSearch search;
342  connect( &search, SIGNAL(data(KLDAP::LdapSearch*,KLDAP::LdapObject)),
343  mParent, SLOT(loadData(KLDAP::LdapSearch*,KLDAP::LdapObject)) );
344  connect( &search, SIGNAL(result(KLDAP::LdapSearch*)),
345  mParent, SLOT(loadResult(KLDAP::LdapSearch*)) );
346 
347  if ( !search.search( _url ) ) {
348  KMessageBox::error( mParent, search.errorString() );
349  return;
350  }
351 
352  if ( mProg == 0 ) {
353  mProg = new KProgressDialog( mParent );
354  mProg->setWindowTitle( i18n( "LDAP Query" ) );
355  mProg->setModal( true );
356  }
357  mProg->setLabelText( _url.prettyUrl() );
358  mProg->progressBar()->setRange( 0, 1 );
359  mProg->progressBar()->setValue( 0 );
360  mProg->exec();
361  if ( mCancelled ) {
362  kDebug() << "query canceled!";
363  search.abandon();
364  } else {
365  if ( search.error() ) {
366  KMessageBox::error( mParent, search.errorString() );
367  }
368  }
369 }
370 
371 void LdapConfigWidget::Private::queryMechClicked()
372 {
373  mAttr = QLatin1String("supportedsaslmechanisms");
374  sendQuery();
375  if ( !mQResult.isEmpty() ) {
376  mQResult.sort();
377  mMech->clear();
378  mMech->addItems( mQResult );
379  }
380 }
381 
382 void LdapConfigWidget::Private::queryDNClicked()
383 {
384  mAttr = QLatin1String("namingcontexts");
385  sendQuery();
386  if ( !mQResult.isEmpty() ) {
387  mDn->setText( mQResult.first() );
388  }
389 }
390 
391 void LdapConfigWidget::Private::loadData( LdapSearch *, const LdapObject &object )
392 {
393  kDebug() << "object:" << object.toString();
394  mProg->progressBar()->setValue( mProg->progressBar()->value() + 1 );
395  LdapAttrMap::ConstIterator end( object.attributes().constEnd() );
396  for ( LdapAttrMap::ConstIterator it = object.attributes().constBegin();
397  it != end; ++it ) {
398  LdapAttrValue::ConstIterator end2( ( *it ).constEnd() );
399  for ( LdapAttrValue::ConstIterator it2 = ( *it ).constBegin();
400  it2 != end2; ++it2 ) {
401  mQResult.push_back( QString::fromUtf8( *it2 ) );
402  }
403  }
404 }
405 
406 void LdapConfigWidget::Private::loadResult( LdapSearch *search )
407 {
408  Q_UNUSED( search );
409  mCancelled = false;
410  mProg->close();
411 }
412 
413 void LdapConfigWidget::Private::setAnonymous( bool on )
414 {
415  if ( !on ) {
416  return;
417  }
418  if ( mUser ) {
419  mUser->setEnabled( false );
420  }
421  if ( mPassword ) {
422  mPassword->setEnabled( false );
423  }
424  if ( mBindDn ) {
425  mBindDn->setEnabled( false );
426  }
427  if ( mRealm ) {
428  mRealm->setEnabled( false );
429  }
430  if ( mMech ) {
431  mMech->setEnabled( false );
432  }
433  if ( mQueryMech ) {
434  mQueryMech->setEnabled( false );
435  }
436 }
437 
438 void LdapConfigWidget::Private::setSimple( bool on )
439 {
440  if ( !on ) {
441  return;
442  }
443  if ( mUser ) {
444  mUser->setEnabled( false );
445  }
446  if ( mPassword ) {
447  mPassword->setEnabled( true );
448  }
449  if ( mBindDn ) {
450  mBindDn->setEnabled( true );
451  }
452  if ( mRealm ) {
453  mRealm->setEnabled( false );
454  }
455  if ( mMech ) {
456  mMech->setEnabled( false );
457  }
458  if ( mQueryMech ) {
459  mQueryMech->setEnabled( false );
460  }
461 }
462 
463 void LdapConfigWidget::Private::setSASL( bool on )
464 {
465  if ( !on ) {
466  return;
467  }
468  if ( mUser ) {
469  mUser->setEnabled( true );
470  }
471  if ( mPassword ) {
472  mPassword->setEnabled( true );
473  }
474  if ( mBindDn ) {
475  mBindDn->setEnabled( true );
476  }
477  if ( mRealm ) {
478  mRealm->setEnabled( true );
479  }
480  if ( mMech ) {
481  mMech->setEnabled( true );
482  }
483  if ( mQueryMech ) {
484  mQueryMech->setEnabled( true );
485  }
486 }
487 
488 void LdapConfigWidget::Private::setLDAPPort()
489 {
490  if ( mPort ) {
491  mPort->setValue( 389 );
492  }
493 }
494 
495 void LdapConfigWidget::Private::setLDAPSPort()
496 {
497  if ( mPort ) {
498  mPort->setValue( 636 );
499  }
500 }
501 
502 LdapConfigWidget::LdapConfigWidget( QWidget *parent, Qt::WindowFlags fl )
503  : QWidget( parent, fl ), d( new Private( this ) )
504 {
505 }
506 
507 LdapConfigWidget::LdapConfigWidget( LdapConfigWidget::WinFlags flags,
508  QWidget *parent, Qt::WindowFlags fl )
509  : QWidget( parent, fl ), d( new Private( this ) )
510 {
511  d->mFeatures = flags;
512 
513  d->initWidget();
514 }
515 
516 LdapConfigWidget::~LdapConfigWidget()
517 {
518  delete d;
519 }
520 
521 LdapUrl LdapConfigWidget::url() const
522 {
523  return server().url();
524 }
525 
526 void LdapConfigWidget::setUrl( const LdapUrl &url )
527 {
528  LdapServer _server;
529  _server.setUrl( url );
530  setServer( _server );
531 }
532 
533 LdapServer LdapConfigWidget::server() const
534 {
535  LdapServer _server;
536  if ( d->mSecSSL && d->mSecSSL->isChecked() ) {
537  _server.setSecurity( LdapServer::SSL );
538  } else if ( d->mSecTLS && d->mSecTLS->isChecked() ) {
539  _server.setSecurity( LdapServer::TLS );
540  } else {
541  _server.setSecurity( LdapServer::None );
542  }
543 
544  if ( d->mUser ) {
545  _server.setUser( d->mUser->text() );
546  }
547  if ( d->mBindDn ) {
548  _server.setBindDn( d->mBindDn->text() );
549  }
550  if ( d->mPassword ) {
551  _server.setPassword( d->mPassword->text() );
552  }
553  if ( d->mRealm ) {
554  _server.setRealm( d->mRealm->text() );
555  }
556  if ( d->mHost ) {
557  _server.setHost( d->mHost->text() );
558  }
559  if ( d->mPort ) {
560  _server.setPort( d->mPort->value() );
561  }
562  if ( d->mDn ) {
563  _server.setBaseDn( LdapDN( d->mDn->text() ) );
564  }
565  if ( d->mFilter ) {
566  _server.setFilter( d->mFilter->text() );
567  }
568  if ( d->mVersion ) {
569  _server.setVersion( d->mVersion->value() );
570  }
571  if ( d->mSizeLimit && d->mSizeLimit->value() != 0 ) {
572  _server.setSizeLimit( d->mSizeLimit->value() );
573  }
574  if ( d->mTimeLimit && d->mTimeLimit->value() != 0 ) {
575  _server.setTimeLimit( d->mTimeLimit->value() );
576  }
577  if ( d->mPageSize && d->mPageSize->value() != 0 ) {
578  _server.setPageSize( d->mPageSize->value() );
579  }
580  if ( d->mAnonymous && d->mAnonymous->isChecked() ) {
581  _server.setAuth( LdapServer::Anonymous );
582  } else if ( d->mSimple && d->mSimple->isChecked() ) {
583  _server.setAuth( LdapServer::Simple );
584  } else if ( d->mSASL && d->mSASL->isChecked() ) {
585  _server.setAuth( LdapServer::SASL );
586  _server.setMech( d->mMech->currentText() );
587  }
588  return _server;
589 }
590 
591 void LdapConfigWidget::setServer( const LdapServer &server )
592 {
593  switch ( server.security() ) {
594  case LdapServer::SSL:
595  if ( d->mSecSSL ) {
596  d->mSecSSL->setChecked( true );
597  }
598  break;
599  case LdapServer::TLS:
600  if ( d->mSecTLS ) {
601  d->mSecTLS->setChecked( true );
602  }
603  break;
604  case LdapServer::None:
605  if ( d->mSecNo ) {
606  d->mSecNo->setChecked( true );
607  }
608  break;
609  }
610 
611  switch ( server.auth() ) {
612  case LdapServer::Anonymous:
613  if ( d->mAnonymous ) {
614  d->mAnonymous->setChecked( true );
615  }
616  break;
617  case LdapServer::Simple:
618  if ( d->mSimple ) {
619  d->mSimple->setChecked( true );
620  }
621  break;
622  case LdapServer::SASL:
623  if ( d->mSASL ) {
624  d->mSASL->setChecked( true );
625  }
626  break;
627  }
628 
629  setUser( server.user() );
630  setBindDn( server.bindDn() );
631  setPassword( server.password() );
632  setRealm( server.realm() );
633  setHost( server.host() );
634  setPort( server.port() );
635  setFilter( server.filter() );
636  setDn( server.baseDn() );
637  setVersion( server.version() );
638  setSizeLimit( server.sizeLimit() );
639  setTimeLimit( server.timeLimit() );
640  setPageSize( server.pageSize() );
641  setMech( server.mech() );
642 }
643 
644 void LdapConfigWidget::setUser( const QString &user )
645 {
646  if ( d->mUser ) {
647  d->mUser->setText( user );
648  }
649 }
650 
651 QString LdapConfigWidget::user() const
652 {
653  return d->mUser ? d->mUser->text() : QString();
654 }
655 
656 void LdapConfigWidget::setPassword( const QString &password )
657 {
658  if ( d->mPassword ) {
659  d->mPassword->setText( password );
660  }
661 }
662 
663 QString LdapConfigWidget::password() const
664 {
665  return d->mPassword ? d->mPassword->text() : QString();
666 }
667 
668 void LdapConfigWidget::setBindDn( const QString &binddn )
669 {
670  if ( d->mBindDn ) {
671  d->mBindDn->setText( binddn );
672  }
673 }
674 
675 QString LdapConfigWidget::bindDn() const
676 {
677  return d->mBindDn ? d->mBindDn->text() : QString();
678 }
679 
680 void LdapConfigWidget::setRealm( const QString &realm )
681 {
682  if ( d->mRealm ) {
683  d->mRealm->setText( realm );
684  }
685 }
686 
687 QString LdapConfigWidget::realm() const
688 {
689  return d->mRealm ? d->mRealm->text() : QString();
690 }
691 
692 void LdapConfigWidget::setHost( const QString &host )
693 {
694  if ( d->mHost ) {
695  d->mHost->setText( host );
696  }
697 }
698 
699 QString LdapConfigWidget::host() const
700 {
701  return d->mHost ? d->mHost->text() : QString();
702 }
703 
704 void LdapConfigWidget::setPort( int port )
705 {
706  if ( d->mPort ) {
707  d->mPort->setValue( port );
708  }
709 }
710 
711 int LdapConfigWidget::port() const
712 {
713  return d->mPort ? d->mPort->value() : 389;
714 }
715 
716 void LdapConfigWidget::setVersion( int version )
717 {
718  if ( d->mVersion ) {
719  d->mVersion->setValue( version );
720  }
721 }
722 
723 int LdapConfigWidget::version() const
724 {
725  return d->mVersion ? d->mVersion->value() : 3;
726 }
727 
728 void LdapConfigWidget::setDn( const LdapDN &dn )
729 {
730  if ( d->mDn ) {
731  d->mDn->setText( dn.toString() );
732  }
733 }
734 
735 LdapDN LdapConfigWidget::dn() const
736 {
737  return d->mDn ? LdapDN( d->mDn->text() ) : LdapDN();
738 }
739 
740 void LdapConfigWidget::setFilter( const QString &filter )
741 {
742  if ( d->mFilter ) {
743  d->mFilter->setText( filter );
744  }
745 }
746 
747 QString LdapConfigWidget::filter() const
748 {
749  return d->mFilter ? d->mFilter->text() : QString();
750 }
751 
752 void LdapConfigWidget::setMech( const QString &mech )
753 {
754  if ( d->mMech == 0 ) {
755  return;
756  }
757  if ( !mech.isEmpty() ) {
758  int i = 0;
759  while ( i < d->mMech->count() ) {
760  if ( d->mMech->itemText( i ) == mech ) {
761  break;
762  }
763  i++;
764  }
765  if ( i == d->mMech->count() ) {
766  d->mMech->addItem( mech );
767  }
768  d->mMech->setCurrentIndex( i );
769  }
770 }
771 
772 QString LdapConfigWidget::mech() const
773 {
774  return d->mMech ? d->mMech->currentText() : QString();
775 }
776 
777 void LdapConfigWidget::setSecurity( Security security )
778 {
779  switch ( security ) {
780  case None:
781  d->mSecNo->setChecked( true );
782  break;
783  case SSL:
784  d->mSecSSL->setChecked( true );
785  break;
786  case TLS:
787  d->mSecTLS->setChecked( true );
788  break;
789  }
790 }
791 
792 LdapConfigWidget::Security LdapConfigWidget::security() const
793 {
794  if ( d->mSecTLS->isChecked() ) {
795  return TLS;
796  }
797  if ( d->mSecSSL->isChecked() ) {
798  return SSL;
799  }
800  return None;
801 }
802 
803 void LdapConfigWidget::setAuth( Auth auth )
804 {
805  switch ( auth ) {
806  case Anonymous:
807  d->mAnonymous->setChecked( true );
808  break;
809  case Simple:
810  d->mSimple->setChecked( true );
811  break;
812  case SASL:
813  d->mSASL->setChecked( true );
814  break;
815  }
816 }
817 
818 LdapConfigWidget::Auth LdapConfigWidget::auth() const
819 {
820  if ( d->mSimple->isChecked() ) {
821  return Simple;
822  }
823  if ( d->mSASL->isChecked() ) {
824  return SASL;
825  }
826  return Anonymous;
827 }
828 
829 void LdapConfigWidget::setSizeLimit( int sizelimit )
830 {
831  if ( d->mSizeLimit ) {
832  d->mSizeLimit->setValue( sizelimit );
833  }
834 }
835 
836 int LdapConfigWidget::sizeLimit() const
837 {
838  return d->mSizeLimit ? d->mSizeLimit->value() : 0;
839 }
840 
841 void LdapConfigWidget::setTimeLimit( int timelimit )
842 {
843  if ( d->mTimeLimit ) {
844  d->mTimeLimit->setValue( timelimit );
845  }
846 }
847 
848 int LdapConfigWidget::timeLimit() const
849 {
850  return d->mTimeLimit ? d->mTimeLimit->value() : 0;
851 }
852 
853 void LdapConfigWidget::setPageSize( int pagesize )
854 {
855  if ( d->mPageSize ) {
856  d->mPageSize->setValue( pagesize );
857  }
858 }
859 
860 int LdapConfigWidget::pageSize() const
861 {
862  return d->mPageSize ? d->mPageSize->value() : 0;
863 }
864 
865 LdapConfigWidget::WinFlags LdapConfigWidget::features() const
866 {
867  return d->mFeatures;
868 }
869 
870 void LdapConfigWidget::setFeatures( LdapConfigWidget::WinFlags features )
871 {
872  d->mFeatures = features;
873 
874  // First delete all the child widgets.
875  // FIXME: I hope it's correct
876  QList<QObject*> ch = children();
877  const int numberOfChild( ch.count() );
878  for ( int i = 0; i < numberOfChild; ++i ) {
879  QWidget *widget = dynamic_cast<QWidget*>( ch[ i ] );
880  if ( widget && widget->parent() == this ) {
881  delete ( widget );
882  }
883  }
884 
885  // Re-create child widgets according to the new flags
886  d->initWidget();
887 }
888 
889 #include "moc_ldapconfigwidget.cpp"
KLDAP::LdapServer::baseDn
LdapDN baseDn() const
Returns the baseDn of the LDAP connection.
Definition: ldapserver.cpp:106
KLDAP::LdapServer::Simple
Authenticate via login and password.
Definition: ldapserver.h:85
KLDAP::LdapConfigWidget::realm
QString realm() const
Gets the SASL realm.
KLDAP::LdapServer::mech
QString mech() const
Returns the mech of the LDAP connection.
Definition: ldapserver.cpp:171
KLDAP::LdapConfigWidget::sizeLimit
int sizeLimit() const
Returns the size limit.
KLDAP::LdapConfigWidget::server
LdapServer server() const
Returns an LdapServer object constructed from the settings given.
Definition: ldapconfigwidget.cpp:533
KLDAP::LdapServer::SASL
Azthenticate with the SASL framework.
Definition: ldapserver.h:86
KLDAP::LdapServer::setBindDn
void setBindDn(const QString &bindDn)
Sets the bindDn of the LDAP connection.
Definition: ldapserver.cpp:201
KLDAP::LdapServer::setAuth
void setAuth(Auth authentication)
Sets the authentication method of the LDAP connection.
Definition: ldapserver.cpp:251
KLDAP::LdapConfigWidget::setSizeLimit
void setSizeLimit(int sizelimit)
Sets the size limit.
Definition: ldapconfigwidget.cpp:829
KLDAP::LdapServer::port
int port() const
Returns the port of the LDAP connection.
Definition: ldapserver.cpp:101
KLDAP::LdapConfigWidget::version
int version() const
Gets the LDAP protocol version.
KLDAP::LdapSearch::search
bool search(const LdapServer &server, const QStringList &attributes=QStringList(), int count=0)
Starts a search operation on the LDAP server.
Definition: ldapsearch.cpp:288
KLDAP::LdapSearch::abandon
void abandon()
Tries to abandon the search.
Definition: ldapsearch.cpp:337
KLDAP::LdapServer::setRealm
void setRealm(const QString &realm)
Sets the realm of the LDAP connection.
Definition: ldapserver.cpp:206
KLDAP::LdapConfigWidget::pageSize
int pageSize() const
Returns the page size.
KLDAP::LdapConfigWidget::security
Security security() const
Returns the security type.
KLDAP::LdapConfigWidget::setPassword
void setPassword(const QString &password)
Sets the password.
Definition: ldapconfigwidget.cpp:656
KLDAP::LdapServer::security
Security security() const
Returns the security mode of the LDAP connection.
Definition: ldapserver.cpp:161
KLDAP::LdapConfigWidget::setUser
void setUser(const QString &user)
Sets the user name.
Definition: ldapconfigwidget.cpp:644
KLDAP::LdapConfigWidget::setHost
void setHost(const QString &host)
Sets the host name.
Definition: ldapconfigwidget.cpp:692
KLDAP::LdapServer::setFilter
void setFilter(const QString &filter)
Sets the filter string of the LDAP connection.
Definition: ldapserver.cpp:231
KLDAP::LdapUrl
A special url class for LDAP.
Definition: ldapurl.h:42
KLDAP::LdapConfigWidget::setRealm
void setRealm(const QString &realm)
Sets the SASL realm.
Definition: ldapconfigwidget.cpp:680
KLDAP::LdapConfigWidget::setMech
void setMech(const QString &mech)
Sets the SASL Mechanism.
Definition: ldapconfigwidget.cpp:752
KLDAP::LdapServer::setBaseDn
void setBaseDn(const LdapDN &baseDn)
Sets the baseDn of the LDAP connection.
Definition: ldapserver.cpp:191
KLDAP::LdapServer::Anonymous
Do no authentication.
Definition: ldapserver.h:84
KLDAP::LdapUrl::setDn
void setDn(const LdapDN &dn)
Sets the dn part of the LDAP url.
Definition: ldapurl.cpp:82
KLDAP::LdapServer::setPassword
void setPassword(const QString &password)
Sets the password of the LDAP connection.
Definition: ldapserver.cpp:211
KLDAP::LdapServer::setTimeLimit
void setTimeLimit(int limit)
Sets the time limit of the LDAP connection.
Definition: ldapserver.cpp:216
KLDAP::LdapSearch::errorString
QString errorString() const
Returns the error description of the search operation.
Definition: ldapsearch.cpp:347
KLDAP::LdapServer::setHost
void setHost(const QString &host)
Sets the host of the LDAP connection.
Definition: ldapserver.cpp:181
KLDAP::LdapServer::setUrl
void setUrl(const LdapUrl &url)
Sets the server parameters from an RFC2255 compliant LDAP url.
Definition: ldapserver.cpp:266
KLDAP::LdapServer::pageSize
int pageSize() const
Returns the page size of the LDAP connection.
Definition: ldapserver.cpp:151
KLDAP::LdapConfigWidget::password
QString password() const
Gets the password.
KLDAP::LdapConfigWidget::dn
LdapDN dn() const
Gets the LDAP Base DN.
KLDAP::LdapConfigWidget::setFilter
void setFilter(const QString &filter)
Sets the LDAP Filter.
Definition: ldapconfigwidget.cpp:740
KLDAP::LdapServer::None
Do not use any encryption.
Definition: ldapserver.h:74
KLDAP::LdapConfigWidget::setSecurity
void setSecurity(Security security)
Sets the security type (None, SSL, TLS).
Definition: ldapconfigwidget.cpp:777
KLDAP::LdapServer::sizeLimit
int sizeLimit() const
Returns the size limit of the LDAP connection.
Definition: ldapserver.cpp:146
KLDAP::LdapServer::TLS
Use TLS encryption.
Definition: ldapserver.h:75
KLDAP::LdapServer::setUser
void setUser(const QString &user)
Sets the user of the LDAP connection.
Definition: ldapserver.cpp:196
KLDAP::LdapConfigWidget::bindDn
QString bindDn() const
Gets the bind dn.
KLDAP::LdapServer::url
LdapUrl url() const
Returns the server parameters as an RFC2255 compliant LDAP Url.
Definition: ldapserver.cpp:349
KLDAP::LdapServer::setSecurity
void setSecurity(Security mode)
Sets the security mode of the LDAP connection.
Definition: ldapserver.cpp:246
KLDAP::LdapServer
A class that contains LDAP server connection settings.
Definition: ldapserver.h:38
KLDAP::LdapServer::setPort
void setPort(int port)
Sets the port of the LDAP connection.
Definition: ldapserver.cpp:186
KLDAP::LdapConfigWidget::setServer
void setServer(const LdapServer &server)
Set up the widget via an LdapServer object.
Definition: ldapconfigwidget.cpp:591
KLDAP::LdapServer::host
QString host() const
Returns the host of the LDAP connection.
Definition: ldapserver.cpp:96
KLDAP::LdapConfigWidget::port
int port() const
Gets the LDAP port.
KLDAP::LdapConfigWidget
LDAP Configuration widget.
Definition: ldapconfigwidget.h:44
KLDAP::LdapServer::setVersion
void setVersion(int version)
Sets the protocol version of the LDAP connection.
Definition: ldapserver.cpp:241
KLDAP::LdapObject
This class represents an LDAP Object.
Definition: ldapobject.h:41
KLDAP::LdapServer::clear
void clear()
Clears all server settings.
Definition: ldapserver.cpp:81
KLDAP::LdapConfigWidget::setUrl
void setUrl(const LdapUrl &url)
Set up the widget via an LDAP Url.
Definition: ldapconfigwidget.cpp:526
KLDAP::LdapConfigWidget::setPort
void setPort(int port)
Sets the LDAP port.
Definition: ldapconfigwidget.cpp:704
KLDAP::LdapConfigWidget::setDn
void setDn(const LdapDN &dn)
Sets the LDAP Base DN.
Definition: ldapconfigwidget.cpp:728
KLDAP::LdapServer::setPageSize
void setPageSize(int size)
Sets the page size of the LDAP connection.
Definition: ldapserver.cpp:226
KLDAP::LdapConfigWidget::filter
QString filter() const
Gets the LDAP Filter.
KLDAP::LdapUrl::Base
Only the same level as the url.
Definition: ldapurl.h:59
KLDAP::LdapSearch
This class starts a search operation on a LDAP server and returns the search values via a Qt signal...
Definition: ldapsearch.h:45
KLDAP::LdapServer::password
QString password() const
Returns the password of the LDAP connection.
Definition: ldapserver.cpp:126
KLDAP::LdapServer::timeLimit
int timeLimit() const
Returns the time limit of the LDAP connection.
Definition: ldapserver.cpp:141
KLDAP::LdapConfigWidget::setTimeLimit
void setTimeLimit(int timelimit)
Sets the time limit.
Definition: ldapconfigwidget.cpp:841
KLDAP::LdapConfigWidget::~LdapConfigWidget
virtual ~LdapConfigWidget()
Destructs a configuration widget.
Definition: ldapconfigwidget.cpp:516
KLDAP::LdapServer::setMech
void setMech(const QString &mech)
Sets the mech of the LDAP connection.
Definition: ldapserver.cpp:256
KLDAP::LdapConfigWidget::url
LdapUrl url() const
Returns a LDAP Url constructed from the settings given.
Definition: ldapconfigwidget.cpp:521
KLDAP::LdapConfigWidget::auth
Auth auth() const
Returns the authentication type.
KLDAP::LdapServer::setSizeLimit
void setSizeLimit(int sizelimit)
Sets the size limit of the LDAP connection.
Definition: ldapserver.cpp:221
KLDAP::LdapServer::bindDn
QString bindDn() const
Returns the bindDn of the LDAP connection.
Definition: ldapserver.cpp:116
KLDAP::LdapServer::SSL
Use SSL encryption.
Definition: ldapserver.h:76
KLDAP::LdapConfigWidget::host
QString host() const
Gets the host name.
KLDAP::LdapConfigWidget::timeLimit
int timeLimit() const
Returns the time limit.
KLDAP::LdapConfigWidget::LdapConfigWidget
LdapConfigWidget(QWidget *parent=0, Qt::WindowFlags fl=0)
Constructs an empty configuration widget.
Definition: ldapconfigwidget.cpp:502
KLDAP::LdapConfigWidget::setVersion
void setVersion(int version)
Sets the LDAP protocol version.
Definition: ldapconfigwidget.cpp:716
KLDAP::LdapServer::realm
QString realm() const
Returns the realm of the LDAP connection.
Definition: ldapserver.cpp:121
KLDAP::LdapConfigWidget::setBindDn
void setBindDn(const QString &binddn)
Sets the bind dn.
Definition: ldapconfigwidget.cpp:668
KLDAP::LdapSearch::error
int error() const
Returns the error code of the search operation (0 if no error).
Definition: ldapsearch.cpp:342
KLDAP::LdapServer::filter
QString filter() const
Returns the filter string of the LDAP connection.
Definition: ldapserver.cpp:131
KLDAP::LdapConfigWidget::setPageSize
void setPageSize(int pagesize)
Sets the page size.
Definition: ldapconfigwidget.cpp:853
KLDAP::LdapServer::version
int version() const
Returns the protocol version of the LDAP connection.
Definition: ldapserver.cpp:156
KLDAP::LdapServer::auth
Auth auth() const
Returns the authentication method of the LDAP connection.
Definition: ldapserver.cpp:166
KLDAP::LdapServer::user
QString user() const
Returns the user of the LDAP connection.
Definition: ldapserver.cpp:111
KLDAP::LdapConfigWidget::user
QString user() const
Gets the user name.
KLDAP::LdapConfigWidget::setAuth
void setAuth(Auth auth)
Sets the authentication type (Anonymous, Simple, SASL).
Definition: ldapconfigwidget.cpp:803
KLDAP::LdapConfigWidget::mech
QString mech() const
Gets the SASL Mechanism.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Jul 21 2014 08:03:33 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KLDAP Library

Skip menu "KLDAP Library"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.13.3 API Reference

Skip menu "kdepimlibs-4.13.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal