Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. $ldapserver = 'server.ip.address';
  2. $ldapuser = '_user_for_search_sAMAccountname';
  3. $ldappass = '_user_pass';
  4. $ldapconn = ldap_connect($ldapserver);
  5. if($ldapconn) {
  6. $ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass);
  7. if ($ldapbind) echo "LDAP bind successful...n";
  8. }
  9.  
  10. services:
  11. app.ldap:
  12. class: SymfonyComponentLdapLdapClient
  13. arguments: [ "server.ip.address" ]
  14.  
  15. security:
  16. role_hierarchy:
  17. ROLE_ADMIN: [ROLE_USER]
  18. providers:
  19. app_users:
  20. ldap:
  21. service: app.ldap
  22. base_dn: ou=staff,dc=ldap,dc=server,dc=com
  23. search_dn: _user_for_search_sAMAccountname
  24. search_password: _user_pass
  25. filter: "(sAMAccountName={username})"
  26. default_roles: ROLE_USER
  27.  
  28. firewalls:
  29. dev:
  30. pattern: ^/(_(profiler|wdt)|css|images|js)/
  31. security: false
  32. main:
  33. provider: app_users
  34. pattern: ^/
  35. logout:
  36. path: /logout
  37. target: /
  38. form_login_ldap:
  39. service: app.ldap
  40. dn_string: "{username}" # !!! differs from default but no luck
  41. check_path: /login_check
  42. login_path: /login
  43. security: true
  44. anonymous: true
  45. access_control:
  46. - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
  47. - { path: /user, roles: ROLE_USER }
  48. - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
  49.  
  50. login:
  51. path: /login
  52. defaults: { _controller: R61IP4BillBundle:Security:login }
  53.  
  54. login_check:
  55. path: /login_check
  56.  
  57. logout:
  58. path: /logout
  59.  
  60. user:
  61. path: /user
  62. defaults: { _controller: R61IP4BillBundle:Default:user }
  63.  
  64. class SecurityController extends Controller
  65. {
  66. public function loginAction(Request $request)
  67. {
  68. $authenticationUtils = $this->get('security.authentication_utils');
  69. $error = $authenticationUtils->getLastAuthenticationError();
  70.  
  71. return $this->render(
  72. 'R61IP4BillBundle:Security:login.html.twig',
  73. array(
  74. 'error' => $error,
  75. )
  76. );
  77. }
  78. }
  79.  
  80. {% if error %}
  81. <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
  82. {% endif %}
  83. <form action="{{ path('login') }}" method="post">
  84. <label for="username">Username:</label>
  85. <input type="text" id="username" name="_username" />
  86.  
  87. <label for="password">Password:</label>
  88. <input type="password" id="password" name="_password" />
  89.  
  90. {#
  91. If you want to control the URL the user
  92. is redirected to on success (more details below)
  93. <input type="hidden" name="_target_path" value="/account" />
  94. #}
  95. <button type="submit">login</button>
  96. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement