]>
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
);
70 xtype
: 'pmxDisplayEditField',
74 editable
: '{isCreate}',
76 fieldLabel
: gettext('Realm'),
80 xtype
: 'proxmoxtextfield',
81 fieldLabel
: gettext('Base Domain Name'),
84 emptyText
: 'cn=Users,dc=company,dc=net',
87 xtype
: 'proxmoxtextfield',
88 fieldLabel
: gettext('User Attribute Name'),
91 emptyText
: 'uid / sAMAccountName',
94 xtype
: 'proxmoxcheckbox',
95 fieldLabel
: gettext('Anonymous Search'),
96 name
: 'anonymous_search',
98 value
: '{anonymous_search}',
102 xtype
: 'proxmoxtextfield',
103 fieldLabel
: gettext('Bind Domain Name'),
106 emptyText
: 'cn=user,dc=company,dc=net',
108 disabled
: "{anonymous_search}",
112 xtype
: 'proxmoxtextfield',
113 inputType
: 'password',
114 fieldLabel
: gettext('Bind Password'),
118 emptyText
: get => !get('isCreate') ? gettext('Unchanged') : '',
121 disabled
: "{anonymous_search}",
128 xtype
: 'proxmoxtextfield',
130 fieldLabel
: gettext('Server'),
134 xtype
: 'proxmoxtextfield',
136 fieldLabel
: gettext('Fallback Server'),
139 deleteEmpty
: '{!isCreate}',
143 xtype
: 'proxmoxintegerfield',
145 fieldLabel
: gettext('Port'),
148 emptyText
: gettext('Default'),
149 submitEmptyText
: false,
153 xtype
: 'proxmoxKVComboBox',
155 fieldLabel
: gettext('Mode'),
159 ['ldap+starttls', 'STARTTLS'],
164 deleteEmpty
: '{!isCreate}',
165 value
: get => get('isCreate') ? 'ldap' : 'LDAP',
169 xtype
: 'proxmoxcheckbox',
170 fieldLabel
: gettext('Verify Certificate'),
174 deleteEmpty
: '{!isCreate}',
178 disabled
: '{!tls_enabled}',
182 'data-qtip': gettext('Verify TLS certificate of the server'),
192 fieldLabel
: gettext('Comment'),
194 deleteEmpty
: '{!isCreate}',
202 Ext
.define('Proxmox.panel.LDAPSyncInputPanel', {
203 extend
: 'Proxmox.panel.InputPanel',
204 xtype
: 'pmxAuthLDAPSyncPanel',
205 mixins
: ['Proxmox.Mixin.CBind'],
207 editableAttributes
: ['firstname', 'lastname', 'email'],
208 editableDefaults
: ['scope', 'enable-new'],
214 // (de)construct the sync-attributes from the list above,
215 // not touching all others
216 onGetValues: function(values
) {
219 me
.editableDefaults
.forEach((attr
) => {
221 me
.default_opts
[attr
] = values
[attr
];
224 delete me
.default_opts
[attr
];
227 let vanished_opts
= [];
228 ['acl', 'entry', 'properties'].forEach((prop
) => {
229 if (values
[`remove-vanished-${prop}`]) {
230 vanished_opts
.push(prop
);
232 delete values
[`remove-vanished-${prop}`];
234 me
.default_opts
['remove-vanished'] = vanished_opts
.join(';');
236 values
['sync-defaults-options'] = Proxmox
.Utils
.printPropertyString(me
.default_opts
);
237 me
.editableAttributes
.forEach((attr
) => {
239 me
.sync_attributes
[attr
] = values
[attr
];
242 delete me
.sync_attributes
[attr
];
245 values
['sync-attributes'] = Proxmox
.Utils
.printPropertyString(me
.sync_attributes
);
247 Proxmox
.Utils
.delete_if_default(values
, 'sync-defaults-options');
248 Proxmox
.Utils
.delete_if_default(values
, 'sync-attributes');
250 // Force values.delete to be an array
251 if (typeof values
.delete === 'string') {
252 values
.delete = values
.delete.split(',');
256 delete values
.delete; // on create we cannot delete values
262 setValues: function(values
) {
265 if (values
['sync-attributes']) {
266 me
.sync_attributes
= Proxmox
.Utils
.parsePropertyString(values
['sync-attributes']);
267 delete values
['sync-attributes'];
268 me
.editableAttributes
.forEach((attr
) => {
269 if (me
.sync_attributes
[attr
]) {
270 values
[attr
] = me
.sync_attributes
[attr
];
274 if (values
['sync-defaults-options']) {
275 me
.default_opts
= Proxmox
.Utils
.parsePropertyString(values
['sync-defaults-options']);
276 delete values
.default_opts
;
277 me
.editableDefaults
.forEach((attr
) => {
278 if (me
.default_opts
[attr
]) {
279 values
[attr
] = me
.default_opts
[attr
];
283 if (me
.default_opts
['remove-vanished']) {
284 let opts
= me
.default_opts
['remove-vanished'].split(';');
285 for (const opt
of opts
) {
286 values
[`remove-vanished-${opt}`] = 1;
290 return me
.callParent([values
]);
295 xtype
: 'proxmoxtextfield',
297 fieldLabel
: gettext('First Name attribute'),
300 xtype
: 'proxmoxtextfield',
302 fieldLabel
: gettext('Last Name attribute'),
305 xtype
: 'proxmoxtextfield',
307 fieldLabel
: gettext('E-Mail attribute'),
310 xtype
: 'displayfield',
311 value
: gettext('Default Sync Options'),
314 xtype
: 'proxmoxKVComboBox',
315 value
: '__default__',
321 gettext("{0} ({1})"),
322 Proxmox
.Utils
.yesText
,
323 Proxmox
.Utils
.defaultText
,
326 ['true', Proxmox
.Utils
.yesText
],
327 ['false', Proxmox
.Utils
.noText
],
330 fieldLabel
: gettext('Enable new users'),
336 xtype
: 'proxmoxtextfield',
337 name
: 'user-classes',
338 fieldLabel
: gettext('User classes'),
340 emptyText
: 'inetorgperson, posixaccount, person, user',
343 'data-qtip': gettext('Default user classes: inetorgperson, posixaccount, person, user'),
347 xtype
: 'proxmoxtextfield',
349 fieldLabel
: gettext('User Filter'),
357 title
: gettext('Remove Vanished Options'),
360 xtype
: 'proxmoxcheckbox',
361 fieldLabel
: gettext('ACL'),
362 name
: 'remove-vanished-acl',
363 boxLabel
: gettext('Remove ACLs of vanished users'),
366 xtype
: 'proxmoxcheckbox',
367 fieldLabel
: gettext('Entry'),
368 name
: 'remove-vanished-entry',
369 boxLabel
: gettext('Remove vanished user'),
372 xtype
: 'proxmoxcheckbox',
373 fieldLabel
: gettext('Properties'),
374 name
: 'remove-vanished-properties',
375 boxLabel
: gettext('Remove vanished properties from synced users.'),