Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <templates>
  3. <template domain="RADIOPK.local">
  4. <dn type="helper" />
  5. <username type="form">username</username>
  6. <password type="form">password_clear</password>
  7. <email type="form">email</email>
  8. <name type="form">name</name>
  9. <attribute name="objectClass" type="string">inetOrgPerson</attribute>
  10. <attribute name="objectClass" type="string">posixAccount</attribute>
  11. <attribute name="objectClass" type="string">shadowAccount</attribute>
  12. <attribute name="gidNumber" type="string">1000</attribute>
  13. <attribute name="givenName" type="helper" />
  14. <attribute name="homeDirectory" type="helper" />
  15. <attribute name="loginShell" type="string">/bin/bash</attribute>
  16. <attribute name="sn" type="helper" />
  17. <attribute name="uidNumber" type="helper" />
  18. </template>
  19. </templates>
  20.  
  21. <?php
  22. /**
  23. * PHP Version 5.3
  24. *
  25. * @package Shmanic.Examples
  26. * @subpackage Ldap
  27. * @author Shaun Maunder <shaun@shmanic.com>
  28. *
  29. * @copyright Copyright (C) 2011-2013 Shaun Maunder. All rights
  30. reserved.
  31. * @license GNU General Public License version 2 or later; see
  32. LICENSE.txt
  33. */
  34. defined('JPATH_PLATFORM') or die;
  35. /**
  36. * LDAP creation helper file for Active Directory.
  37. *
  38. * @package Shmanic.Examples
  39. * @subpackage Ldap
  40. * @since 2.0
  41. */
  42. final class LdapCreation_RADIOPK.local
  43. {
  44. /**
  45. * Returns the distinguished name.
  46. *
  47. * @param array $form Registration form.
  48. *
  49. * @return string Distinguished name.
  50. *
  51. * @since 2.0
  52. */
  53. public function getMandatoryDN($form)
  54. {
  55. $name = SHLdapHelper::escape($form['username'], true);
  56. return "uid={$username},OU=WebApps-Users,OU=WebApps,DC=RadioPK,DC=local";
  57. }
  58. /**
  59. * Returns the first name.
  60. *
  61. * @param array $form Registration form.
  62. *
  63. * @return string Last name.
  64. *
  65. * @since 2.0
  66. */
  67. public function getGivenName($form)
  68. {
  69. return $this->genFirstname($form['name']);
  70. }
  71. /**
  72. * Returns the last name.
  73. *
  74. * @param array $form Registration form.
  75. *
  76. * @return string Last name.
  77. *
  78. * @since 2.0
  79. */
  80. public function getSn($form)
  81. {
  82. return $this->genLastname($form['name']);
  83. }
  84. /**
  85. * Returns the correct userPrincipalName.
  86. *
  87. * @param array $form Registration form.
  88. *
  89. * @return string userPrincipalName.
  90. *
  91. * @since 2.0
  92. */
  93. public function getUserPrincipalName($form)
  94. {
  95. return $form['username'] . '@RadioPK.local';
  96. }
  97. /**
  98. * Splits the full name using a space and returns the first section.
  99. * If no space is detected, then the whole name is returned.
  100. *
  101. * @param string $name Full name.
  102. *
  103. * @return string First name.
  104. *
  105. * @since 2.0
  106. */
  107. protected function genFirstname($name)
  108. {
  109. if ($pos = strrpos($name, ' '))
  110. {
  111. // Space detected therefore return first section.
  112. return substr($name, 0, $pos);
  113. }
  114. return $name;
  115. }
  116. /**
  117. * Splits the full name using a space and returns the last section.
  118. * If no space is detected, then the whole name is returned.
  119. *
  120. * @param string $name Full name.
  121. *
  122. * @return string Last name.
  123. *
  124. * @since 2.0
  125. */
  126. protected function genLastname($name)
  127. {
  128. // Get the last name (if no space then return whole name)
  129. if ($pos = strrpos($name, ' '))
  130. {
  131. return substr($name, $pos + 1);
  132. }
  133. return $name;
  134. }
  135. /**
  136. * Method is called after the user is created in LDAP. This can be used to run external
  137. * scripts (such as creating home directories) and/or adding groups to the new user.
  138. *
  139. * @param array $form Values directly from the user registration form.
  140. * @param array $attributes The attributes passed to the LDAP server for creation.
  141. * @param SHUserAdapter $adapter The user adapter object.
  142. *
  143. * @return void
  144. *
  145. * @since 2.0
  146. */
  147. public function onAfterCreation($form, $attributes, $adapter)
  148. {
  149. }
  150. }
  151. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement