0011190: can't activate TLS for LDAP connections
[tine20] / tine20 / Setup / js / AuthenticationPanel.js
1 /*
2  * Tine 2.0
3  * 
4  * @package     Setup
5  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
6  * @author      Cornelius Weiss <c.weiss@metaways.de>
7  * @copyright   Copyright (c) 2009-2015 Metaways Infosystems GmbH (http://www.metaways.de)
8  *
9  */
10
11 /*global Ext, Tine*/
12
13 Ext.ns('Tine', 'Tine.Setup');
14  
15 /**
16  * Setup Authentication Manager
17  * 
18  * @namespace   Tine.Setup
19  * @class       Tine.Setup.AuthenticationPanel
20  * @extends     Tine.Tinebase.widgets.form.ConfigPanel
21  * 
22  * <p>Authentication Panel</p>
23  * <p><pre>
24  * TODO         move to next step after install?
25  * TODO         make default is valid mechanism with 'allowEmpty' work
26  * TODO         add port for ldap hosts
27  * </pre></p>
28  * 
29  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
30  * @author      Cornelius Weiss <c.weiss@metaways.de>
31  * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
32  * 
33  * @param       {Object} config
34  * @constructor
35  * Create a new Tine.Setup.AuthenticationPanel
36  */
37 Tine.Setup.AuthenticationPanel = Ext.extend(Tine.Tinebase.widgets.form.ConfigPanel, {
38     
39     /**
40      * @property idPrefix DOM Id prefix
41      * @type String
42      */
43     idPrefix: null,
44     
45     /**
46      * authProviderPrefix DOM Id prefix
47      * 
48      * @property authProviderIdPrefix
49      * @type String
50      */
51     authProviderIdPrefix: null,
52     
53     /**
54      * accountsStorageIdPrefix DOM Id prefix
55      * 
56      * @property accountsStorageIdPrefix
57      * @type String
58      */
59     accountsStorageIdPrefix: null,
60     
61     /**
62      * combo box containing the authentication backend selection
63      * 
64      * @property authenticationBackendCombo
65      * @type Ext.form.ComboBox 
66      */
67     authenticationBackendCombo: null,
68
69     /**
70      * combo box containing the accounts storage selection
71      * 
72      * @property accountsStorageCombo
73      * @type Ext.form.ComboBox
74      */
75     accountsStorageCombo: null,
76     
77     /**
78      * The currently active accounts storage backend
79      * 
80      * @property originalAccountsStorage
81      * @type String
82      */
83     originalAccountsStorage: null,
84
85     /**
86      * @private
87      * panel cfg
88      */
89     saveMethod: 'Setup.saveAuthentication',
90     registryKey: 'authenticationData',
91     
92     /**
93      * @private
94      * field index counter
95      */
96     tabIndexCounter: 1,
97     
98     /**
99      * @private
100      */
101     initComponent: function () {
102         this.idPrefix                   = Ext.id();
103         this.authProviderIdPrefix       = this.idPrefix + '-authProvider-';
104         this.accountsStorageIdPrefix    = this.idPrefix + '-accountsStorage-';
105         this.originalAccountsStorage    = (Tine.Setup.registry.get(this.registryKey).accounts) ? Tine.Setup.registry.get(this.registryKey).accounts.backend : 'Sql';
106         
107         Tine.Setup.AuthenticationPanel.superclass.initComponent.call(this);
108     },
109     
110     /**
111      * Change card layout depending on selected combo box entry
112      */
113     onChangeAuthProvider: function () {
114         var authProvider = this.authenticationBackendCombo.getValue();
115         
116         var cardLayout = Ext.getCmp(this.authProviderIdPrefix + 'CardLayout').getLayout();
117         cardLayout.setActiveItem(this.authProviderIdPrefix + authProvider);
118     },
119     
120     /**
121      * Change card layout depending on selected combo box entry
122      */
123     onChangeAccountsStorage: function () {
124         var AccountsStorage = this.accountsStorageCombo.getValue();
125
126         if ((AccountsStorage === 'Ldap' || AccountsStorage === 'ActiveDirectory') && AccountsStorage !== this.originalAccountsStorage) {
127             Ext.Msg.confirm(this.app.i18n._('Delete all existing users and groups'), this.app.i18n._('Switching from SQL to LDAP will delete all existing User Accounts, Groups and Roles. Do you really want to switch the accounts storage backend to LDAP ?'), function (confirmbtn, value) {
128                 if (confirmbtn === 'yes') {
129                     this.doOnChangeAccountsStorage(AccountsStorage);
130                 } else {
131                     this.accountsStorageCombo.setValue(this.originalAccountsStorage);
132                 }
133             }, this);
134         } else {
135             this.doOnChangeAccountsStorage(AccountsStorage);
136         }
137     },
138     
139     /**
140      * Change card layout depending on selected combo box entry
141      */
142     doOnChangeAccountsStorage: function (AccountsStorage) {
143         var cardLayout = Ext.getCmp(this.accountsStorageIdPrefix + 'CardLayout').getLayout();
144         
145         cardLayout.setActiveItem(this.accountsStorageIdPrefix + AccountsStorage);
146         this.originalAccountsStorage = AccountsStorage;
147     },
148     
149     /**
150      * @private
151      */
152     onRender: function (ct, position) {
153         Tine.Setup.AuthenticationPanel.superclass.onRender.call(this, ct, position);
154         
155         this.onChangeAuthProvider.defer(250, this);
156         this.onChangeAccountsStorage.defer(250, this);
157     },
158         
159     /**
160      * transforms form data into a config object
161      * 
162      * @hack   smuggle termsAccept in 
163      * @return {Object} configData
164      */
165     form2config: function () {
166         var configData = this.supr().form2config.call(this);
167         configData.acceptedTermsVersion = Tine.Setup.registry.get('acceptedTermsVersion');
168         
169         return configData;
170     },
171     
172     /**
173      * get tab index for field
174      * 
175      * @return {Integer}
176      */
177     getTabIndex: function () {
178         return this.tabIndexCounter++;
179     },
180     
181    /**
182      * returns config manager form
183      * 
184      * @private
185      * @return {Array} items
186      */
187     getFormItems: function () {
188         var setupRequired = Tine.Setup.registry.get('setupRequired');
189         
190         // common config for all combos in this setup
191         var commonComboConfig = {
192             xtype: 'combo',
193             listWidth: 300,
194             mode: 'local',
195             forceSelection: true,
196             allowEmpty: false,
197             triggerAction: 'all',
198             editable: false,
199             tabIndex: this.getTabIndex
200         };
201         
202         this.authenticationBackendCombo = new Ext.form.ComboBox(Ext.applyIf({
203             name: 'authentication_backend',
204             fieldLabel: this.app.i18n._('Backend'),
205             store: [['Sql', 'SQL'], ['Ldap', 'LDAP'], ['Imap', 'IMAP'], ['ModSsl', this.app.i18n._('TLS client certificate')]],
206             value: 'Sql',
207             width: 300,
208             listeners: {
209                 scope: this,
210                 change: this.onChangeAuthProvider,
211                 select: this.onChangeAuthProvider
212             }
213         }, commonComboConfig));
214             
215         this.accountsStorageCombo = new Ext.form.ComboBox(Ext.applyIf({
216             name: 'accounts_backend',
217             fieldLabel: this.app.i18n._('Backend'),
218             store: [['Sql', 'Sql'], ['Ldap', 'Ldap'], ['ActiveDirectory', 'ActiveDirectory']],
219             value: 'Sql',
220             width: 300,
221             listeners: {
222                 scope: this,
223                 change: this.onChangeAccountsStorage,
224                 select: this.onChangeAccountsStorage
225             }
226         }, commonComboConfig));
227         
228         return [{
229             xtype: 'fieldset',
230             collapsible: true,
231             collapsed: !setupRequired,
232             autoHeight: true,
233             title: this.app.i18n._('Initial Admin User'),
234             items: [{
235                 layout: 'form',
236                 autoHeight: 'auto',
237                 border: false,
238                 defaults: {
239                     width: 300,
240                     xtype: 'textfield',
241                     inputType: 'password',
242                     tabIndex: this.getTabIndex
243                 },
244                 items: [{
245                     name: 'authentication_Sql_adminLoginName',
246                     fieldLabel: this.app.i18n._('Initial admin login name'),
247                     inputType: 'text',
248                     disabled: !setupRequired
249                 }, {
250                     name: 'authentication_Sql_adminPassword',
251                     fieldLabel: this.app.i18n._('Initial admin Password'),
252                     disabled: !setupRequired
253                 }, {
254                     name: 'authentication_Sql_adminPasswordConfirmation',
255                     fieldLabel: this.app.i18n._('Password confirmation'),
256                     disabled: !setupRequired
257                 }]
258             }]
259         }, {
260             xtype: 'fieldset',
261             collapsible: false,
262             autoHeight: true,
263             title: this.app.i18n._('Authentication provider'),
264             items: [
265                 this.authenticationBackendCombo,
266                 {
267                     id: this.authProviderIdPrefix + 'CardLayout',
268                     layout: 'card',
269                     activeItem: this.authProviderIdPrefix + 'Sql',
270                     border: false,
271                     defaults: {border: false},
272                     items: [{
273                         id: this.authProviderIdPrefix + 'Sql',
274                         layout: 'form',
275                         autoHeight: 'auto',
276                         defaults: {
277                             width: 300,
278                             xtype: 'textfield',
279                             tabIndex: this.getTabIndex
280                         },
281                         items: [
282                             Ext.applyIf({
283                                 name: 'authentication_Sql_tryUsernameSplit',
284                                 fieldLabel: this.app.i18n._('Try to split username'),
285                                 store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
286                                 value: '1'
287                             }, commonComboConfig), 
288                             Ext.applyIf({
289                                 name: 'authentication_Sql_accountCanonicalForm',
290                                 fieldLabel: this.app.i18n._('Account canonical form'),
291                                 store: [['2', 'ACCTNAME_FORM_USERNAME'], ['3', 'ACCTNAME_FORM_BACKSLASH'], ['4', 'ACCTNAME_FORM_PRINCIPAL']],
292                                 value: '2'
293                             }, commonComboConfig), 
294                             {
295                                 name: 'authentication_Sql_accountDomainName',
296                                 fieldLabel: this.app.i18n._('Account domain name ')
297                             }, {
298                                 name: 'authentication_Sql_accountDomainNameShort',
299                                 fieldLabel: this.app.i18n._('Account domain short name')
300                             }
301                         ]
302                     }, {
303                         id: this.authProviderIdPrefix + 'Ldap',
304                         layout: 'form',
305                         autoHeight: 'auto',
306                         defaults: {
307                             width: 300,
308                             xtype: 'textfield',
309                             tabIndex: this.getTabIndex
310                         },
311                         items: [{
312                             name: 'authentication_Ldap_host',
313                             fieldLabel: this.app.i18n._('Host')
314                         }/*, {
315                             inputType: 'text',
316                             name: 'authentication_Ldap_port',
317                             fieldLabel: this.app.i18n._('Port')
318                         }*/, {
319                             name: 'authentication_Ldap_username',
320                             fieldLabel: this.app.i18n._('Login name')
321                         }, {
322                             name: 'authentication_Ldap_password',
323                             fieldLabel: this.app.i18n._('Password'),
324                             inputType: 'password'
325                         },
326                         Ext.applyIf({
327                             name: 'authentication_Ldap_bindRequiresDn',
328                             fieldLabel: this.app.i18n._('Bind requires DN'),
329                             store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
330                             value: '1'
331                         }, commonComboConfig),
332                         Ext.applyIf({
333                             name: 'authentication_Ldap_useStartTls',
334                             fieldLabel: this.app.i18n._('Start TLS'),
335                             store: [['0', this.app.i18n._('No')], ['1', this.app.i18n._('Yes')]],
336                             value: '0'
337                         }, commonComboConfig), 
338                         {
339                             name: 'authentication_Ldap_baseDn',
340                             fieldLabel: this.app.i18n._('Base DN')
341                         }, {
342                             name: 'authentication_Ldap_accountFilterFormat',
343                             fieldLabel: this.app.i18n._('Search filter')
344                         }, 
345                         Ext.applyIf({
346                             name: 'authentication_Ldap_accountCanonicalForm',
347                             fieldLabel: this.app.i18n._('Account canonical form'),
348                             store: [['2', 'ACCTNAME_FORM_USERNAME'], ['3', 'ACCTNAME_FORM_BACKSLASH'], ['4', 'ACCTNAME_FORM_PRINCIPAL']],
349                             value: '2'
350                         }, commonComboConfig), 
351                         {
352                             name: 'authentication_Ldap_accountDomainName',
353                             fieldLabel: this.app.i18n._('Account domain name ')
354                         }, {
355                             name: 'authentication_Ldap_accountDomainNameShort',
356                             fieldLabel: this.app.i18n._('Account domain short name')
357                         }]
358                     }, {
359                         id: this.authProviderIdPrefix + 'Imap',
360                         layout: 'form',
361                         autoHeight: 'auto',
362                         defaults: {
363                             width: 300,
364                             xtype: 'textfield',
365                             tabIndex: this.getTabIndex
366                         },
367                         items: [{
368                             name: 'authentication_Imap_host',
369                             fieldLabel: this.app.i18n._('Hostname')
370                         }, {
371                             name: 'authentication_Imap_port',
372                             fieldLabel: this.app.i18n._('Port'),
373                             xtype: 'numberfield'
374                         }, 
375                         Ext.applyIf({
376                             fieldLabel: this.app.i18n._('Secure Connection'),
377                             name: 'authentication_Imap_ssl',
378                             store: [['none', this.app.i18n._('None')], ['tls', this.app.i18n._('TLS')], ['ssl', this.app.i18n._('SSL')]],
379                             value: 'none'
380                         }, commonComboConfig), 
381                         {
382                             name: 'authentication_Imap_domain',
383                             fieldLabel: this.app.i18n._('Append domain to login name')
384                         }
385                         ]
386                     }, {
387                         id: this.authProviderIdPrefix + 'ModSsl',
388                         layout: 'form',
389                         autoHeight: 'auto',
390                         defaults: {
391                             width: 300,
392                             xtype: 'textfield',
393                             tabIndex: this.getTabIndex
394                         },
395                         items: [Ext.applyIf({
396                             fieldLabel: this.app.i18n._('Certificate validation'),
397                             name: 'authentication_ModSsl_validation',
398                             store: [['Apache', 'Apache'], ['X509', 'X509'], ['ICPBrasil', 'ICP Brasil']],
399                             value: 'Apache'
400                         }, commonComboConfig),
401                         Ext.applyIf({
402                             name: 'authentication_ModSsl_tryUsernameSplit',
403                             fieldLabel: this.app.i18n._('Try to split username'),
404                             store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
405                             value: '1'
406                         }, commonComboConfig), 
407                         {
408                             name: 'authentication_ModSsl_casfile',
409                             fieldLabel: this.app.i18n._('CA file')
410                         }, {
411                             name: 'authentication_ModSsl_crlspath',
412                             fieldLabel: this.app.i18n._('CRL directory')
413                         }
414                         ]
415                     }]
416                 }
417             ]
418         }, {
419             xtype: 'fieldset',
420             collapsible: false,
421             autoHeight: true,
422             title: this.app.i18n._('Accounts storage'),
423             items: [
424                 this.accountsStorageCombo,
425                 {
426                     id: this.accountsStorageIdPrefix + 'CardLayout',
427                     layout: 'card',
428                     activeItem: this.accountsStorageIdPrefix + 'Sql',
429                     border: false,
430                     defaults: {
431                         border: false
432                     },
433                     items: [{
434                         id: this.accountsStorageIdPrefix + 'Sql',
435                         layout: 'form',
436                         autoHeight: 'auto',
437                         defaults: {
438                             width: 300,
439                             xtype: 'textfield',
440                             tabIndex: this.getTabIndex
441                         },
442                         items: [{
443                             name: 'accounts_Sql_defaultUserGroupName',
444                             fieldLabel: this.app.i18n._('Default user group name')
445                         }, {
446                             name: 'accounts_Sql_defaultAdminGroupName',
447                             fieldLabel: this.app.i18n._('Default admin group name')
448                         }]
449                     },
450                         this.getDirectoryOptions('Ldap', commonComboConfig),
451                         this.getDirectoryOptions('ActiveDirectory', commonComboConfig)
452                     ]
453                 }
454             ]
455           }, {
456             xtype: 'fieldset',
457             collapsible: false,
458             autoHeight: true,
459             title: this.app.i18n._('Login panel'),
460             defaults: {
461                 width: 300,
462                 xtype: 'uxspinner',
463                 tabIndex: this.getTabIndex,
464                 strategy: {
465                     xtype: 'number',
466                     minValue: 0,
467                     maxValue: 64
468                 },
469                 value: 0
470             },
471             items: [
472             Ext.applyIf({
473                 name: 'saveusername_saveusername',
474                 fieldLabel: this.app.i18n._('Reuse last username logged'),
475                 store: [[1, this.app.i18n._('Yes')], [0, this.app.i18n._('No')]],
476                 value: 0
477             }, commonComboConfig)
478             ]
479         }, {
480             xtype: 'fieldset',
481             collapsible: false,
482             autoHeight: true,
483             title: this.app.i18n._('Password Settings'),
484             defaults: {
485                 width: 300,
486                 xtype: 'uxspinner',
487                 tabIndex: this.getTabIndex,
488                 strategy: {
489                     xtype: 'number',
490                     minValue: 0,
491                     maxValue: 64
492                 },
493                 value: 0
494             },
495             items: [
496             Ext.applyIf({
497                 name: 'password_changepw',
498                 fieldLabel: this.app.i18n._('User can change password'),
499                 store: [[1, this.app.i18n._('Yes')], [0, this.app.i18n._('No')]],
500                 value: 1
501             }, commonComboConfig),
502             Ext.applyIf({
503                 name: 'password_pwPolicyActive',
504                 fieldLabel: this.app.i18n._('Enable password policy'),
505                 store: [[1, this.app.i18n._('Yes')], [0, this.app.i18n._('No')]],
506                 value: 0
507             }, commonComboConfig),
508             Ext.applyIf({
509                 name: 'password_pwPolicyOnlyASCII',
510                 fieldLabel: this.app.i18n._('Only ASCII'),
511                 store: [[1, this.app.i18n._('Yes')], [0, this.app.i18n._('No')]],
512                 value: 0
513             }, commonComboConfig), {
514                 name: 'password_pwPolicyMinLength',
515                 fieldLabel: this.app.i18n._('Minimum length')
516             }, {
517                 name: 'password_pwPolicyMinWordChars',
518                 fieldLabel: this.app.i18n._('Minimum word chars')
519             }, {
520                 name: 'password_pwPolicyMinUppercaseChars',
521                 fieldLabel: this.app.i18n._('Minimum uppercase chars')
522             }, {
523                 name: 'password_pwPolicyMinSpecialChars',
524                 fieldLabel: this.app.i18n._('Minimum special chars')
525             }, {
526                 name: 'password_pwPolicyMinNumbers',
527                 fieldLabel: this.app.i18n._('Minimum numbers')
528             },
529             Ext.applyIf({
530                 name: 'password_pwPolicyForbidUsername',
531                 fieldLabel: this.app.i18n._('Forbid part of username in password'),
532                 store: [[1, this.app.i18n._('Yes')], [0, this.app.i18n._('No')]],
533                 value: 0
534             }, commonComboConfig)
535             ]
536         }, {
537             xtype: 'fieldset',
538             collapsible: false,
539             autoHeight: true,
540             title: this.app.i18n._('Redirect Settings'),
541             defaults: {
542                 width: 300,
543                 xtype: 'textfield',
544                 tabIndex: this.getTabIndex
545             },
546             items: [{
547                 name: 'redirectSettings_redirectUrl',
548                 fieldLabel: this.app.i18n._('Redirect Url (redirect to login screen if empty)')
549             }, 
550             Ext.applyIf({
551                 name: 'redirectSettings_redirectAlways',
552                 fieldLabel: this.app.i18n._('Redirect Always (if No, only redirect after logout)'),
553                 store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
554                 value: '0'
555             }, commonComboConfig), 
556             Ext.applyIf({
557                 name: 'redirectSettings_redirectToReferrer',
558                 fieldLabel: this.app.i18n._('Redirect to referring site, if exists'),
559                 store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
560                 value: '0'
561             }, commonComboConfig)]
562         }];
563     },
564     
565     /**
566      * getDirectoryOptions
567      * 
568      * @param {String} type LDAP or ActiveDirectory
569      * @param {Object} commonComboConfig
570      */
571     getDirectoryOptions: function(type, commonComboConfig)
572     {
573         return {
574             id: this.accountsStorageIdPrefix + type,
575             layout: 'form',
576             autoHeight: 'auto',
577             defaults: {
578                 width: 300,
579                 xtype: 'textfield',
580                 tabIndex: this.getTabIndex
581             },
582             items: [{
583                 name: 'accounts_' + type + '_host',
584                 fieldLabel: this.app.i18n._('Host')
585             }, {
586                 name: 'accounts_' + type + '_username',
587                 fieldLabel: this.app.i18n._('Login name')
588             }, {
589                 name: 'accounts_' + type + '_password',
590                 fieldLabel: this.app.i18n._('Password'),
591                 inputType: 'password'
592             }, 
593             Ext.applyIf({
594                 name: 'accounts_' + type + '_bindRequiresDn',
595                 fieldLabel: this.app.i18n._('Bind requires DN'),
596                 store: [['1', this.app.i18n._('Yes')], ['0', this.app.i18n._('No')]],
597                 value: '1'
598             }, commonComboConfig),
599             Ext.applyIf({
600                 name: 'accounts_' + type + '_useStartTls',
601                 fieldLabel: this.app.i18n._('Start TLS'),
602                 store: [['0', this.app.i18n._('No')], ['1', this.app.i18n._('Yes')]],
603                 value: '0'
604             }, commonComboConfig),
605             Ext.applyIf({
606                 hidden: type === 'ActiveDirectory' ,
607                 name: 'accounts_' + type + '_pwEncType',
608                 fieldLabel: this.app.i18n._('Password encoding'),
609                 store: [
610                     ['des', this.app.i18n._('des')],
611                     ['crypt', this.app.i18n._('crypt')],
612                     ['blowfish_crypt', this.app.i18n._('blowfish_crypt')],
613                     ['md5_crypt', this.app.i18n._('md5_crypt')],
614                     ['ext_crypt', this.app.i18n._('ext_crypt')],
615                     ['md5', this.app.i18n._('md5')],
616                     ['smd5', this.app.i18n._('smd5')],
617                     ['sha', this.app.i18n._('sha')],
618                     ['ssha', this.app.i18n._('ssha')],
619                     ['ntpassword', this.app.i18n._('ntpassword')],
620                     ['plain', this.app.i18n._('plain')]
621                 ],
622                 value: 'ssha'
623             }, commonComboConfig),
624             {
625                 name: 'accounts_' + type + '_userDn',
626                 fieldLabel: this.app.i18n._('User DN')
627             }, {
628                 name: 'accounts_' + type + '_userFilter',
629                 fieldLabel: this.app.i18n._('User Filter')
630             }, 
631             Ext.applyIf({
632                 name: 'accounts_' + type + '_userSearchScope',
633                 fieldLabel: this.app.i18n._('User Search Scope'),
634                 store: [['1', 'SEARCH_SCOPE_SUB'], ['2', 'SEARCH_SCOPE_ONE']],
635                 value: '1'
636             }, commonComboConfig), 
637             {
638                 name: 'accounts_' + type + '_groupsDn',
639                 fieldLabel: this.app.i18n._('Groups DN')
640             }, {
641                 name: 'accounts_' + type + '_groupFilter',
642                 fieldLabel: this.app.i18n._('Group Filter')
643             }, 
644             Ext.applyIf({
645                 name: 'accounts_' + type + '_groupSearchScope',
646                 fieldLabel: this.app.i18n._('Group Search Scope'),
647                 store: [['1', 'SEARCH_SCOPE_SUB'], ['2', 'SEARCH_SCOPE_ONE']],
648                 value: '1'
649             }, commonComboConfig), 
650             Ext.applyIf({
651                 name: 'accounts_' + type + (type === 'Ldap') ? '_useRfc2307bis' : '_useRfc2307',
652                 fieldLabel: (type === 'Ldap') ? this.app.i18n._('Use Rfc 2307 bis') : this.app.i18n._('Maintain RFC 2307 attributes'),
653                 store: [['0', this.app.i18n._('No')], ['1', this.app.i18n._('Yes')]],
654                 value: '0'
655             }, commonComboConfig), 
656             {
657                 name: 'accounts_' + type + '_minUserId',
658                 fieldLabel: this.app.i18n._('Min User Id')
659             }, {
660                 name: 'accounts_' + type + '_maxUserId',
661                 fieldLabel: this.app.i18n._('Max User Id')
662             }, {
663                 name: 'accounts_' + type + '_minGroupId',
664                 fieldLabel: this.app.i18n._('Min Group Id')
665             }, {
666                 name: 'accounts_' + type + '_maxGroupId',
667                 fieldLabel: this.app.i18n._('Max Group Id')
668             },
669             Ext.applyIf({
670                 name: 'accounts_' + type + '_groupUUIDAttribute',
671                 fieldLabel: this.app.i18n._('Group UUID Attribute name'),
672                 store: (type === 'ActiveDirectory' ? [['objectGUID', 'objectGUID']] : [['entryUUID', 'entryUUID'], ['gidNumber', 'gidNumber']])
673             }, commonComboConfig),
674             Ext.applyIf({
675                 name: 'accounts_' + type + '_userUUIDAttribute',
676                 fieldLabel: this.app.i18n._('User UUID Attribute name'),
677                 store: (type === 'ActiveDirectory' ? [['objectGUID', 'objectGUID']] : [['entryUUID', 'entryUUID'], ['uidNumber', 'uidNumber']])
678             }, commonComboConfig),
679             {
680                 name: 'accounts_' + type + '_defaultUserGroupName',
681                 fieldLabel: this.app.i18n._('Default user group name')
682             }, {
683                 name: 'accounts_' + type + '_defaultAdminGroupName',
684                 fieldLabel: this.app.i18n._('Default admin group name')
685             },
686             Ext.applyIf({
687                 name: 'accounts_' + type + '_readonly',
688                 fieldLabel: this.app.i18n._('Readonly access'),
689                 store: [['0', this.app.i18n._('No')], ['1', this.app.i18n._('Yes')]],
690                 value: '0'
691             }, commonComboConfig)]
692         };
693     },
694     
695     /**
696      * applies registry state to this cmp
697      */
698     applyRegistryState: function () {
699         this.action_saveConfig.setDisabled(false);
700         
701         if (Tine.Setup.registry.get('setupRequired')) {
702             this.action_saveConfig.setText(this.app.i18n._('Save config and install'));
703         } else {
704             this.action_saveConfig.setText(this.app.i18n._('Save config'));
705             this.getForm().findField('authentication_Sql_adminPassword').setDisabled(true);
706             this.getForm().findField('authentication_Sql_adminPasswordConfirmation').setDisabled(true);
707             this.getForm().findField('authentication_Sql_adminLoginName').setDisabled(true);
708         }
709     },
710     
711     /**
712      * checks if form is valid
713      * - password fields are equal
714      * 
715      * @return {Boolean}
716      */
717     isValid: function () {
718         var form = this.getForm();
719
720         var result = form.isValid();
721         
722         // check if passwords match
723         if (this.authenticationBackendCombo.getValue() === 'Sql' && 
724             form.findField('authentication_Sql_adminPassword') && 
725             form.findField('authentication_Sql_adminPassword').getValue() !== form.findField('authentication_Sql_adminPasswordConfirmation').getValue()) 
726         {
727             form.markInvalid([{
728                 id: 'authentication_Sql_adminPasswordConfirmation',
729                 msg: this.app.i18n._("Passwords don't match")
730             }]);
731             result = false;
732         }
733         
734         // check if initial username/passwords are set
735         if (Tine.Setup.registry.get('setupRequired')
736             && form.findField('authentication_Sql_adminLoginName')
737             && ! form.findField('authentication_Sql_adminLoginName').disabled) 
738         {
739             if (Ext.isEmpty(form.findField('authentication_Sql_adminLoginName').getValue())) {
740                 form.markInvalid([{
741                     id: 'authentication_Sql_adminLoginName',
742                     msg: this.app.i18n._("Should not be empty")
743                 }]);
744                 result = false;
745             }
746             if (Ext.isEmpty(form.findField('authentication_Sql_adminPassword').getValue())) {
747                 form.markInvalid([{
748                     id: 'authentication_Sql_adminPassword',
749                     msg: this.app.i18n._("Should not be empty")
750                 }]);
751                 form.markInvalid([{
752                     id: 'authentication_Sql_adminPasswordConfirmation',
753                     msg: this.app.i18n._("Should not be empty")
754                 }]);
755                 result = false;
756             }
757         }
758         
759         if (this.accountsStorageCombo.getValue() === 'Sql' && 
760                form.findField('accounts_Sql_defaultUserGroupName') && 
761                Ext.isEmpty(form.findField('accounts_Sql_defaultUserGroupName').getValue())) 
762           {
763             form.markInvalid([{
764                 id: 'accounts_Sql_defaultUserGroupName',
765                 msg: this.app.i18n._("Should not be empty")
766             }]);
767             result = false;
768         }
769         
770         if (this.accountsStorageCombo.getValue() === 'Sql' && 
771             form.findField('accounts_Sql_defaultAdminGroupName') && 
772             Ext.isEmpty(form.findField('accounts_Sql_defaultAdminGroupName').getValue())) 
773         {
774             form.markInvalid([{
775                 id: 'accounts_Sql_defaultAdminGroupName',
776                 msg: this.app.i18n._("Should not be empty")
777             }]);
778             result = false;
779         }
780         
781         return result;
782     }
783 });