]>
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
) {
35 if (this.isCreate
&& !this.useTypeInUrl
) {
36 values
.type
= this.type
;
39 if (values
.anonymous_search
&& !this.isCreate
) {
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,
170 deleteEmpty
: '{!isCreate}',
174 xtype
: 'proxmoxKVComboBox',
176 fieldLabel
: gettext('Mode'),
180 ['ldap+starttls', 'STARTTLS'],
185 deleteEmpty
: '{!isCreate}',
186 value
: get => get('isCreate') ? 'ldap' : 'LDAP',
190 xtype
: 'proxmoxcheckbox',
191 fieldLabel
: gettext('Verify Certificate'),
195 deleteEmpty
: '{!isCreate}',
199 disabled
: '{!tls_enabled}',
203 'data-qtip': gettext('Verify TLS certificate of the server'),
211 xtype
: 'proxmoxtextfield',
213 fieldLabel
: gettext('Comment'),
215 deleteEmpty
: '{!isCreate}',
223 Ext
.define('Proxmox.panel.LDAPSyncInputPanel', {
224 extend
: 'Proxmox.panel.InputPanel',
225 xtype
: 'pmxAuthLDAPSyncPanel',
226 mixins
: ['Proxmox.Mixin.CBind'],
228 editableAttributes
: ['firstname', 'lastname', 'email'],
229 editableDefaults
: ['scope', 'enable-new'],
235 // (de)construct the sync-attributes from the list above,
236 // not touching all others
237 onGetValues: function(values
) {
240 me
.editableDefaults
.forEach((attr
) => {
242 me
.default_opts
[attr
] = values
[attr
];
245 delete me
.default_opts
[attr
];
248 let vanished_opts
= [];
249 ['acl', 'entry', 'properties'].forEach((prop
) => {
250 if (values
[`remove-vanished-${prop}`]) {
251 vanished_opts
.push(prop
);
253 delete values
[`remove-vanished-${prop}`];
255 me
.default_opts
['remove-vanished'] = vanished_opts
.join(';');
257 values
['sync-defaults-options'] = Proxmox
.Utils
.printPropertyString(me
.default_opts
);
258 me
.editableAttributes
.forEach((attr
) => {
260 me
.sync_attributes
[attr
] = values
[attr
];
263 delete me
.sync_attributes
[attr
];
266 values
['sync-attributes'] = Proxmox
.Utils
.printPropertyString(me
.sync_attributes
);
268 Proxmox
.Utils
.delete_if_default(values
, 'sync-defaults-options');
269 Proxmox
.Utils
.delete_if_default(values
, 'sync-attributes');
271 // Force values.delete to be an array
272 if (typeof values
.delete === 'string') {
273 values
.delete = values
.delete.split(',');
277 delete values
.delete; // on create we cannot delete values
283 setValues: function(values
) {
286 if (values
['sync-attributes']) {
287 me
.sync_attributes
= Proxmox
.Utils
.parsePropertyString(values
['sync-attributes']);
288 delete values
['sync-attributes'];
289 me
.editableAttributes
.forEach((attr
) => {
290 if (me
.sync_attributes
[attr
]) {
291 values
[attr
] = me
.sync_attributes
[attr
];
295 if (values
['sync-defaults-options']) {
296 me
.default_opts
= Proxmox
.Utils
.parsePropertyString(values
['sync-defaults-options']);
297 delete values
.default_opts
;
298 me
.editableDefaults
.forEach((attr
) => {
299 if (me
.default_opts
[attr
]) {
300 values
[attr
] = me
.default_opts
[attr
];
304 if (me
.default_opts
['remove-vanished']) {
305 let opts
= me
.default_opts
['remove-vanished'].split(';');
306 for (const opt
of opts
) {
307 values
[`remove-vanished-${opt}`] = 1;
311 return me
.callParent([values
]);
316 xtype
: 'proxmoxtextfield',
318 fieldLabel
: gettext('First Name attribute'),
321 'data-qtip': Ext
.String
.format(gettext('Often called {0}'), '`givenName`'),
325 xtype
: 'proxmoxtextfield',
327 fieldLabel
: gettext('Last Name attribute'),
330 'data-qtip': Ext
.String
.format(gettext('Often called {0}'), '`sn`'),
334 xtype
: 'proxmoxtextfield',
336 fieldLabel
: gettext('E-Mail attribute'),
339 'data-qtip': get => get('isAd')
340 ? Ext
.String
.format(gettext('Often called {0} or {1}'), '`userPrincipalName`', '`mail`')
341 : Ext
.String
.format(gettext('Often called {0}'), '`mail`'),
345 xtype
: 'displayfield',
346 value
: gettext('Default Sync Options'),
349 xtype
: 'proxmoxKVComboBox',
350 value
: '__default__',
356 gettext("{0} ({1})"),
357 Proxmox
.Utils
.yesText
,
358 Proxmox
.Utils
.defaultText
,
361 ['true', Proxmox
.Utils
.yesText
],
362 ['false', Proxmox
.Utils
.noText
],
365 fieldLabel
: gettext('Enable new users'),
371 xtype
: 'proxmoxtextfield',
372 name
: 'user-classes',
373 fieldLabel
: gettext('User classes'),
375 deleteEmpty
: '{!isCreate}',
377 emptyText
: 'inetorgperson, posixaccount, person, user',
380 'data-qtip': gettext('Default user classes: inetorgperson, posixaccount, person, user'),
384 xtype
: 'proxmoxtextfield',
386 fieldLabel
: gettext('User Filter'),
388 deleteEmpty
: '{!isCreate}',
396 title
: gettext('Remove Vanished Options'),
399 xtype
: 'proxmoxcheckbox',
400 fieldLabel
: gettext('ACL'),
401 name
: 'remove-vanished-acl',
402 boxLabel
: gettext('Remove ACLs of vanished users'),
405 xtype
: 'proxmoxcheckbox',
406 fieldLabel
: gettext('Entry'),
407 name
: 'remove-vanished-entry',
408 boxLabel
: gettext('Remove vanished user'),
411 xtype
: 'proxmoxcheckbox',
412 fieldLabel
: gettext('Properties'),
413 name
: 'remove-vanished-properties',
414 boxLabel
: gettext('Remove vanished properties from synced users.'),