wizardTabAdvanced.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /**
  2. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. OCA = OCA || {};
  7. (function() {
  8. /**
  9. * @classdesc This class represents the view belonging to the advanced tab
  10. * in the LDAP wizard.
  11. */
  12. var WizardTabAdvanced = OCA.LDAP.Wizard.WizardTabGeneric.subClass({
  13. /**
  14. * initializes the instance. Always call it after initialization.
  15. *
  16. * @param {any} tabIndex -
  17. * @param {any} tabID -
  18. */
  19. init: function (tabIndex, tabID) {
  20. this._super(tabIndex, tabID);
  21. var items = {
  22. // Connection settings
  23. ldap_configuration_active: {
  24. $element: $('#ldap_configuration_active'),
  25. setMethod: 'setConfigurationState'
  26. },
  27. ldap_backup_host: {
  28. $element: $('#ldap_backup_host'),
  29. setMethod: 'setBackupHost'
  30. },
  31. ldap_backup_port: {
  32. $element: $('#ldap_backup_port'),
  33. setMethod: 'setBackupPort'
  34. },
  35. ldap_override_main_server: {
  36. $element: $('#ldap_override_main_server'),
  37. setMethod: 'setOverrideMainServerState'
  38. },
  39. ldap_turn_off_cert_check: {
  40. $element: $('#ldap_turn_off_cert_check'),
  41. setMethod: 'setCertCheckDisabled'
  42. },
  43. ldap_cache_ttl: {
  44. $element: $('#ldap_cache_ttl'),
  45. setMethod: 'setCacheTTL'
  46. },
  47. //Directory Settings
  48. ldap_display_name: {
  49. $element: $('#ldap_display_name'),
  50. setMethod: 'setUserDisplayName'
  51. },
  52. ldap_user_display_name_2: {
  53. $element: $('#ldap_user_display_name_2'),
  54. setMethod: 'setUserDisplayName2'
  55. },
  56. ldap_base_users: {
  57. $element: $('#ldap_base_users'),
  58. setMethod: 'setBaseDNUsers'
  59. },
  60. ldap_attributes_for_user_search: {
  61. $element: $('#ldap_attributes_for_user_search'),
  62. setMethod: 'setSearchAttributesUsers'
  63. },
  64. ldap_mark_remnants_as_disabled: {
  65. $element: $('#ldap_mark_remnants_as_disabled'),
  66. setMethod: 'setMarkRemnantsAsDisabled'
  67. },
  68. ldap_group_display_name: {
  69. $element: $('#ldap_group_display_name'),
  70. setMethod: 'setGroupDisplayName'
  71. },
  72. ldap_base_groups: {
  73. $element: $('#ldap_base_groups'),
  74. setMethod: 'setBaseDNGroups'
  75. },
  76. ldap_attributes_for_group_search: {
  77. $element: $('#ldap_attributes_for_group_search'),
  78. setMethod: 'setSearchAttributesGroups'
  79. },
  80. ldap_group_member_assoc_attribute: {
  81. $element: $('#ldap_group_member_assoc_attribute'),
  82. setMethod: 'setGroupMemberAssociationAttribute'
  83. },
  84. ldap_dynamic_group_member_url: {
  85. $element: $('#ldap_dynamic_group_member_url'),
  86. setMethod: 'setDynamicGroupMemberURL'
  87. },
  88. ldap_nested_groups: {
  89. $element: $('#ldap_nested_groups'),
  90. setMethod: 'setUseNestedGroups'
  91. },
  92. ldap_paging_size: {
  93. $element: $('#ldap_paging_size'),
  94. setMethod: 'setPagingSize'
  95. },
  96. ldap_turn_on_pwd_change: {
  97. $element: $('#ldap_turn_on_pwd_change'),
  98. setMethod: 'setPasswordChangeEnabled'
  99. },
  100. ldap_default_ppolicy_dn: {
  101. $element: $('#ldap_default_ppolicy_dn'),
  102. setMethod: 'setDefaultPPolicyDN'
  103. },
  104. //Special Attributes
  105. ldap_quota_attr: {
  106. $element: $('#ldap_quota_attr'),
  107. setMethod: 'setQuotaAttribute'
  108. },
  109. ldap_quota_def: {
  110. $element: $('#ldap_quota_def'),
  111. setMethod: 'setQuotaDefault'
  112. },
  113. ldap_email_attr: {
  114. $element: $('#ldap_email_attr'),
  115. setMethod: 'setEmailAttribute'
  116. },
  117. home_folder_naming_rule: {
  118. $element: $('#home_folder_naming_rule'),
  119. setMethod: 'setHomeFolderAttribute'
  120. },
  121. ldap_ext_storage_home_attribute: {
  122. $element: $('#ldap_ext_storage_home_attribute'),
  123. setMethod: 'setExternalStorageHomeAttribute'
  124. },
  125. //User Profile Attributes
  126. ldap_attr_phone: {
  127. $element: $('#ldap_attr_phone'),
  128. setMethod: 'setPhoneAttribute'
  129. },
  130. ldap_attr_website: {
  131. $element: $('#ldap_attr_website'),
  132. setMethod: 'setWebsiteAttribute'
  133. },
  134. ldap_attr_address: {
  135. $element: $('#ldap_attr_address'),
  136. setMethod: 'setAddressAttribute'
  137. },
  138. ldap_attr_twitter: {
  139. $element: $('#ldap_attr_twitter'),
  140. setMethod: 'setTwitterAttribute'
  141. },
  142. ldap_attr_fediverse: {
  143. $element: $('#ldap_attr_fediverse'),
  144. setMethod: 'setFediverseAttribute'
  145. },
  146. ldap_attr_organisation: {
  147. $element: $('#ldap_attr_organisation'),
  148. setMethod: 'setOrganisationAttribute'
  149. },
  150. ldap_attr_role: {
  151. $element: $('#ldap_attr_role'),
  152. setMethod: 'setRoleAttribute'
  153. },
  154. ldap_attr_headline: {
  155. $element: $('#ldap_attr_headline'),
  156. setMethod: 'setHeadlineAttribute'
  157. },
  158. ldap_attr_biography: {
  159. $element: $('#ldap_attr_biography'),
  160. setMethod: 'setBiographyAttribute'
  161. },
  162. ldap_attr_birthdate: {
  163. $element: $('#ldap_attr_birthdate'),
  164. setMethod: 'setBirthdateAttribute'
  165. },
  166. };
  167. this.setManagedItems(items);
  168. },
  169. /**
  170. * Sets the config model for this view and subscribes to some events.
  171. * Also binds the config chooser to the model
  172. *
  173. * @param {OCA.LDAP.Wizard.ConfigModel} configModel
  174. */
  175. setModel: function(configModel) {
  176. this._super(configModel);
  177. this.configModel.on('configLoaded', this.onConfigLoaded, this);
  178. this.configModel.on('receivedLdapFeature', this.onResultReceived, this);
  179. },
  180. /**
  181. * updates the experienced admin check box
  182. *
  183. * @param {string} isConfigActive contains an int
  184. */
  185. setConfigurationState: function(isConfigActive) {
  186. this.setElementValue(
  187. this.managedItems.ldap_configuration_active.$element, isConfigActive
  188. );
  189. },
  190. /**
  191. * updates the backup host configuration text field
  192. *
  193. * @param {string} host
  194. */
  195. setBackupHost: function(host) {
  196. this.setElementValue(this.managedItems.ldap_backup_host.$element, host);
  197. },
  198. /**
  199. * updates the backup port configuration text field
  200. *
  201. * @param {string} port
  202. */
  203. setBackupPort: function(port) {
  204. this.setElementValue(this.managedItems.ldap_backup_port.$element, port);
  205. },
  206. /**
  207. * sets whether the main server should be overridden or not
  208. *
  209. * @param {string} doOverride contains an int
  210. */
  211. setOverrideMainServerState: function(doOverride) {
  212. this.setElementValue(
  213. this.managedItems.ldap_override_main_server.$element, doOverride
  214. );
  215. },
  216. /**
  217. * sets whether the SSL/TLS certification check shout be disabled
  218. *
  219. * @param {string} doCertCheck contains an int
  220. */
  221. setCertCheckDisabled: function(doCertCheck) {
  222. this.setElementValue(
  223. this.managedItems.ldap_turn_off_cert_check.$element, doCertCheck
  224. );
  225. },
  226. /**
  227. * sets the time-to-live of the LDAP cache (in seconds)
  228. *
  229. * @param {string} cacheTTL contains an int
  230. */
  231. setCacheTTL: function(cacheTTL) {
  232. this.setElementValue(this.managedItems.ldap_cache_ttl.$element, cacheTTL);
  233. },
  234. /**
  235. * sets the user display name attribute
  236. *
  237. * @param {string} attribute
  238. */
  239. setUserDisplayName: function(attribute) {
  240. this.setElementValue(this.managedItems.ldap_display_name.$element, attribute);
  241. },
  242. /**
  243. * sets the additional user display name attribute
  244. *
  245. * @param {string} attribute
  246. */
  247. setUserDisplayName2: function(attribute) {
  248. this.setElementValue(this.managedItems.ldap_user_display_name_2.$element, attribute);
  249. },
  250. /**
  251. * sets the Base DN for users
  252. *
  253. * @param {string} base
  254. */
  255. setBaseDNUsers: function(base) {
  256. this.setElementValue(this.managedItems.ldap_base_users.$element, base);
  257. },
  258. /**
  259. * sets the attributes for user searches
  260. *
  261. * @param {string} attributes
  262. */
  263. setSearchAttributesUsers: function(attributes) {
  264. this.setElementValue(this.managedItems.ldap_attributes_for_user_search.$element, attributes);
  265. },
  266. /**
  267. * enables or disables marking remnants as disabled
  268. *
  269. * @param {string} markRemnantsAsDisabled contains an int
  270. */
  271. setMarkRemnantsAsDisabled: function(markRemnantsAsDisabled) {
  272. this.setElementValue(this.managedItems.ldap_mark_remnants_as_disabled.$element, markRemnantsAsDisabled);
  273. },
  274. /**
  275. * sets the display name attribute for groups
  276. *
  277. * @param {string} attribute
  278. */
  279. setGroupDisplayName: function(attribute) {
  280. this.setElementValue(this.managedItems.ldap_group_display_name.$element, attribute);
  281. },
  282. /**
  283. * sets the Base DN for groups
  284. *
  285. * @param {string} base
  286. */
  287. setBaseDNGroups: function(base) {
  288. this.setElementValue(this.managedItems.ldap_base_groups.$element, base);
  289. },
  290. /**
  291. * sets the attributes for group search
  292. *
  293. * @param {string} attributes
  294. */
  295. setSearchAttributesGroups: function(attributes) {
  296. this.setElementValue(this.managedItems.ldap_attributes_for_group_search.$element, attributes);
  297. },
  298. /**
  299. * sets the attribute for the association of users and groups
  300. *
  301. * @param {string} attribute
  302. */
  303. setGroupMemberAssociationAttribute: function(attribute) {
  304. this.setElementValue(this.managedItems.ldap_group_member_assoc_attribute.$element, attribute);
  305. },
  306. /**
  307. * sets the dynamic group member url attribute
  308. *
  309. * @param {string} attribute
  310. */
  311. setDynamicGroupMemberURL: function(attribute) {
  312. this.setElementValue(this.managedItems.ldap_dynamic_group_member_url.$element, attribute);
  313. },
  314. /**
  315. * enabled or disables the use of nested groups (groups in groups in
  316. * groups…)
  317. *
  318. * @param {string} useNestedGroups contains an int
  319. */
  320. setUseNestedGroups: function(useNestedGroups) {
  321. this.setElementValue(this.managedItems.ldap_nested_groups.$element, useNestedGroups);
  322. },
  323. /**
  324. * sets the size of pages for paged search
  325. *
  326. * @param {string} size contains an int
  327. */
  328. setPagingSize: function(size) {
  329. this.setElementValue(this.managedItems.ldap_paging_size.$element, size);
  330. },
  331. /**
  332. * sets whether the password changes per user should be enabled
  333. *
  334. * @param {string} doPasswordChange contains an int
  335. */
  336. setPasswordChangeEnabled: function(doPasswordChange) {
  337. this.setElementValue(
  338. this.managedItems.ldap_turn_on_pwd_change.$element, doPasswordChange
  339. );
  340. },
  341. /**
  342. * sets the default ppolicy attribute
  343. *
  344. * @param {string} attribute
  345. */
  346. setDefaultPPolicyDN: function(attribute) {
  347. this.setElementValue(this.managedItems.ldap_default_ppolicy_dn.$element, attribute);
  348. },
  349. /**
  350. * sets the email attribute
  351. *
  352. * @param {string} attribute
  353. */
  354. setEmailAttribute: function(attribute) {
  355. this.setElementValue(this.managedItems.ldap_email_attr.$element, attribute);
  356. },
  357. /**
  358. * sets the external storage home attribute
  359. *
  360. * @param {string} attribute
  361. */
  362. setExternalStorageHomeAttribute: function(attribute) {
  363. this.setElementValue(this.managedItems.ldap_ext_storage_home_attribute.$element, attribute);
  364. },
  365. /**
  366. * sets the quota attribute
  367. *
  368. * @param {string} attribute
  369. */
  370. setQuotaAttribute: function(attribute) {
  371. this.setElementValue(this.managedItems.ldap_quota_attr.$element, attribute);
  372. },
  373. /**
  374. * sets the default quota for LDAP users
  375. *
  376. * @param {string} quota contains an int
  377. */
  378. setQuotaDefault: function(quota) {
  379. this.setElementValue(this.managedItems.ldap_quota_def.$element, quota);
  380. },
  381. /**
  382. * sets the attribute for the Nextcloud user specific home folder location
  383. *
  384. * @param {string} attribute
  385. */
  386. setHomeFolderAttribute: function(attribute) {
  387. this.setElementValue(this.managedItems.home_folder_naming_rule.$element, attribute);
  388. },
  389. /**
  390. * sets the attribute for the Nextcloud user profile phone Number
  391. *
  392. * @param {string} attribute
  393. */
  394. setPhoneAttribute: function(attribute) {
  395. this.setElementValue(this.managedItems.ldap_attr_phone.$element, attribute);
  396. },
  397. /**
  398. * sets the attribute for the Nextcloud user profile website
  399. *
  400. * @param {string} attribute
  401. */
  402. setWebsiteAttribute: function(attribute) {
  403. this.setElementValue(this.managedItems.ldap_attr_website.$element, attribute);
  404. },
  405. /**
  406. * sets the attribute for the Nextcloud user profile postal address
  407. *
  408. * @param {string} attribute
  409. */
  410. setAddressAttribute: function(attribute) {
  411. this.setElementValue(this.managedItems.ldap_attr_address.$element, attribute);
  412. },
  413. /**
  414. * sets the attribute for the Nextcloud user profile twitter
  415. *
  416. * @param {string} attribute
  417. */
  418. setTwitterAttribute: function(attribute) {
  419. this.setElementValue(this.managedItems.ldap_attr_twitter.$element, attribute);
  420. },
  421. /**
  422. * sets the attribute for the Nextcloud user profile fediverse
  423. *
  424. * @param {string} attribute
  425. */
  426. setFediverseAttribute: function(attribute) {
  427. this.setElementValue(this.managedItems.ldap_attr_fediverse.$element, attribute);
  428. },
  429. /**
  430. * sets the attribute for the Nextcloud user profile organisation
  431. *
  432. * @param {string} attribute
  433. */
  434. setOrganisationAttribute: function(attribute) {
  435. this.setElementValue(this.managedItems.ldap_attr_organisation.$element, attribute);
  436. },
  437. /**
  438. * sets the attribute for the Nextcloud user profile role
  439. *
  440. * @param {string} attribute
  441. */
  442. setRoleAttribute: function(attribute) {
  443. this.setElementValue(this.managedItems.ldap_attr_role.$element, attribute);
  444. },
  445. /**
  446. * sets the attribute for the Nextcloud user profile headline
  447. *
  448. * @param {string} attribute
  449. */
  450. setHeadlineAttribute: function(attribute) {
  451. this.setElementValue(this.managedItems.ldap_attr_headline.$element, attribute);
  452. },
  453. /**
  454. * sets the attribute for the Nextcloud user profile biography
  455. *
  456. * @param {string} attribute
  457. */
  458. setBiographyAttribute: function(attribute) {
  459. this.setElementValue(this.managedItems.ldap_attr_biography.$element, attribute);
  460. },
  461. /**
  462. * sets the attribute for the Nextcloud user profile birthday
  463. *
  464. * @param {string} attribute
  465. */
  466. setBirthdateAttribute: function(attribute) {
  467. this.setElementValue(this.managedItems.ldap_attr_birthdate.$element, attribute);
  468. },
  469. /**
  470. * deals with the result of the Test Connection test
  471. *
  472. * @param {WizardTabAdvanced} view
  473. * @param {FeaturePayload} payload
  474. */
  475. onResultReceived: function(view, payload) {
  476. if(payload.feature === 'TestConfiguration') {
  477. OC.Notification.showTemporary(payload.data.message);
  478. }
  479. }
  480. });
  481. OCA.LDAP.Wizard.WizardTabAdvanced = WizardTabAdvanced;
  482. })();