]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - src/window/AuthEditLDAP.js
2 Ext
.define('Proxmox.panel.LDAPInputPanelViewModel', {
3 extend
: 'Ext.app.ViewModel',
5 alias
: 'viewmodel.pmxAuthLDAPPanel',
13 tls_enabled: function(get) {
14 return get('mode') !== 'ldap';
21 Ext
.define('Proxmox.panel.LDAPInputPanel', {
22 extend
: 'Proxmox.panel.InputPanel',
23 xtype
: 'pmxAuthLDAPPanel',
24 mixins
: ['Proxmox.Mixin.CBind'],
27 type
: 'pmxAuthLDAPPanel',
32 onlineHelp
: 'user-realms-ldap',
34 onGetValues: function(values
) {
36 values
.type
= this.type
;
39 if (values
.anonymous_search
) {
44 if (!Array
.isArray(values
.delete)) {
45 let tmp
= values
.delete;
47 values
.delete.push(tmp
);
50 values
.delete.push("bind-dn");
51 values
.delete.push("password");
54 delete values
.anonymous_search
;
59 onSetValues: function(values
) {
61 values
.anonymous_search
= values
["bind-dn"] ? 0 : 1;
62 me
.getViewModel().set('anonymous_search', values
.anonymous_search
);
67 cbindData: function(config
) {
69 isLdap
: this.type
=== 'ldap',
70 isAd
: this.type
=== 'ad',
76 xtype
: 'pmxDisplayEditField',
80 editable
: '{isCreate}',
82 fieldLabel
: gettext('Realm'),
86 xtype
: 'proxmoxtextfield',
87 fieldLabel
: gettext('Base Domain Name'),
89 emptyText
: 'cn=Users,dc=company,dc=net',
92 allowBlank
: '{!isLdap}',
96 xtype
: 'proxmoxtextfield',
97 fieldLabel
: gettext('User Attribute Name'),
99 emptyText
: 'uid / sAMAccountName',
102 allowBlank
: '{!isLdap}',
106 xtype
: 'proxmoxcheckbox',
107 fieldLabel
: gettext('Anonymous Search'),
108 name
: 'anonymous_search',
110 value
: '{anonymous_search}',
114 xtype
: 'proxmoxtextfield',
115 fieldLabel
: gettext('Bind Domain Name'),
119 emptyText
: get => get('isAd') ? 'user@company.net' : 'cn=user,dc=company,dc=net',
120 autoEl
: get => get('isAd') ? {
123 gettext('LDAP DN syntax can be used as well, e.g. cn=user,dc=company,dc=net'),
127 disabled
: "{anonymous_search}",
131 xtype
: 'proxmoxtextfield',
132 inputType
: 'password',
133 fieldLabel
: gettext('Bind Password'),
136 emptyText
: get => !get('isCreate') ? gettext('Unchanged') : '',
137 allowBlank
: '{!isCreate}',
140 disabled
: "{anonymous_search}",
147 xtype
: 'proxmoxtextfield',
149 fieldLabel
: gettext('Server'),
153 xtype
: 'proxmoxtextfield',
155 fieldLabel
: gettext('Fallback Server'),
158 deleteEmpty
: '{!isCreate}',
162 xtype
: 'proxmoxintegerfield',
164 fieldLabel
: gettext('Port'),
167 emptyText
: gettext('Default'),
168 submitEmptyText
: false,
172 xtype
: 'proxmoxKVComboBox',
174 fieldLabel
: gettext('Mode'),
178 ['ldap+starttls', 'STARTTLS'],
183 deleteEmpty
: '{!isCreate}',
184 value
: get => get('isCreate') ? 'ldap' : 'LDAP',
188 xtype
: 'proxmoxcheckbox',
189 fieldLabel
: gettext('Verify Certificate'),
193 deleteEmpty
: '{!isCreate}',
197 disabled
: '{!tls_enabled}',
201 'data-qtip': gettext('Verify TLS certificate of the server'),
209 xtype
: 'proxmoxtextfield',
211 fieldLabel
: gettext('Comment'),
213 deleteEmpty
: '{!isCreate}',
221 Ext
.define('Proxmox.panel.LDAPSyncInputPanel', {
222 extend
: 'Proxmox.panel.InputPanel',
223 xtype
: 'pmxAuthLDAPSyncPanel',
224 mixins
: ['Proxmox.Mixin.CBind'],
226 editableAttributes
: ['firstname', 'lastname', 'email'],
227 editableDefaults
: ['scope', 'enable-new'],
233 // (de)construct the sync-attributes from the list above,
234 // not touching all others
235 onGetValues: function(values
) {
238 me
.editableDefaults
.forEach((attr
) => {
240 me
.default_opts
[attr
] = values
[attr
];
243 delete me
.default_opts
[attr
];
246 let vanished_opts
= [];
247 ['acl', 'entry', 'properties'].forEach((prop
) => {
248 if (values
[`remove-vanished-${prop}`]) {
249 vanished_opts
.push(prop
);
251 delete values
[`remove-vanished-${prop}`];
253 me
.default_opts
['remove-vanished'] = vanished_opts
.join(';');
255 values
['sync-defaults-options'] = Proxmox
.Utils
.printPropertyString(me
.default_opts
);
256 me
.editableAttributes
.forEach((attr
) => {
258 me
.sync_attributes
[attr
] = values
[attr
];
261 delete me
.sync_attributes
[attr
];
264 values
['sync-attributes'] = Proxmox
.Utils
.printPropertyString(me
.sync_attributes
);
266 Proxmox
.Utils
.delete_if_default(values
, 'sync-defaults-options');
267 Proxmox
.Utils
.delete_if_default(values
, 'sync-attributes');
269 // Force values.delete to be an array
270 if (typeof values
.delete === 'string') {
271 values
.delete = values
.delete.split(',');
275 delete values
.delete; // on create we cannot delete values
281 setValues: function(values
) {
284 if (values
['sync-attributes']) {
285 me
.sync_attributes
= Proxmox
.Utils
.parsePropertyString(values
['sync-attributes']);
286 delete values
['sync-attributes'];
287 me
.editableAttributes
.forEach((attr
) => {
288 if (me
.sync_attributes
[attr
]) {
289 values
[attr
] = me
.sync_attributes
[attr
];
293 if (values
['sync-defaults-options']) {
294 me
.default_opts
= Proxmox
.Utils
.parsePropertyString(values
['sync-defaults-options']);
295 delete values
.default_opts
;
296 me
.editableDefaults
.forEach((attr
) => {
297 if (me
.default_opts
[attr
]) {
298 values
[attr
] = me
.default_opts
[attr
];
302 if (me
.default_opts
['remove-vanished']) {
303 let opts
= me
.default_opts
['remove-vanished'].split(';');
304 for (const opt
of opts
) {
305 values
[`remove-vanished-${opt}`] = 1;
309 return me
.callParent([values
]);
314 xtype
: 'proxmoxtextfield',
316 fieldLabel
: gettext('First Name attribute'),
319 'data-qtip': Ext
.String
.format(gettext('Often called {0}'), '`givenName`'),
323 xtype
: 'proxmoxtextfield',
325 fieldLabel
: gettext('Last Name attribute'),
328 'data-qtip': Ext
.String
.format(gettext('Often called {0}'), '`sn`'),
332 xtype
: 'proxmoxtextfield',
334 fieldLabel
: gettext('E-Mail attribute'),
337 'data-qtip': get => get('isAd')
338 ? Ext
.String
.format(gettext('Often called {0} or {1}'), '`userPrincipalName`', '`mail`')
339 : Ext
.String
.format(gettext('Often called {0}'), '`mail`'),
343 xtype
: 'displayfield',
344 value
: gettext('Default Sync Options'),
347 xtype
: 'proxmoxKVComboBox',
348 value
: '__default__',
354 gettext("{0} ({1})"),
355 Proxmox
.Utils
.yesText
,
356 Proxmox
.Utils
.defaultText
,
359 ['true', Proxmox
.Utils
.yesText
],
360 ['false', Proxmox
.Utils
.noText
],
363 fieldLabel
: gettext('Enable new users'),
369 xtype
: 'proxmoxtextfield',
370 name
: 'user-classes',
371 fieldLabel
: gettext('User classes'),
373 emptyText
: 'inetorgperson, posixaccount, person, user',
376 'data-qtip': gettext('Default user classes: inetorgperson, posixaccount, person, user'),
380 xtype
: 'proxmoxtextfield',
382 fieldLabel
: gettext('User Filter'),
390 title
: gettext('Remove Vanished Options'),
393 xtype
: 'proxmoxcheckbox',
394 fieldLabel
: gettext('ACL'),
395 name
: 'remove-vanished-acl',
396 boxLabel
: gettext('Remove ACLs of vanished users'),
399 xtype
: 'proxmoxcheckbox',
400 fieldLabel
: gettext('Entry'),
401 name
: 'remove-vanished-entry',
402 boxLabel
: gettext('Remove vanished user'),
405 xtype
: 'proxmoxcheckbox',
406 fieldLabel
: gettext('Properties'),
407 name
: 'remove-vanished-properties',
408 boxLabel
: gettext('Remove vanished properties from synced users.'),