Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

FR3DLdapBundle and Symfony 2.1 #15

Closed
symfony24 opened this issue Oct 31, 2012 · 8 comments
Closed

FR3DLdapBundle and Symfony 2.1 #15

symfony24 opened this issue Oct 31, 2012 · 8 comments

Comments

@symfony24
Copy link

i try to use FR3DLdapBundle in Symfony 2.1, but there is no documentation to install it.
please help

@symfony24
Copy link
Author

i have this error:
Fatal error: Class 'FR3D\LdapBundle\FR3DLdapBundle' not found in /var/www/Symfony/app/AppKernel.php on line 26
besides, i have this tree in my project: /vendor/bundles/FR3D/LdapBundle/FR3DLdapBundle.php

@Maks3w
Copy link
Owner

Maks3w commented Oct 31, 2012

Hi @symfony24

With Symfony 2.1 you should add the bundle using the Composer package fr3d/ldap-bundle and add it to your AppKernel as the same way of the rest of bundles.

Anyway in 1.6 and 2.0 branch there are documentation about how to install it with SF 2.1

https://github.com/Maks3w/FR3DLdapBundle/blob/1.6.x/Resources/doc/index.md
https://github.com/Maks3w/FR3DLdapBundle/blob/2.0.x/Resources/doc/index.md

@symfony24
Copy link
Author

thx a lot, now, i'm trying to authenticate, i have this error:
The credentials you have configured are not valid

this is my config.yml

fos_user:
db_driver: orm
firewall_name: main
user_class: Talan\VpnBundle\Entity\User

fr3d_ldap:
client:
host: 192.168.8.95
port: 389 # Optional

version: 3 # Optional
username: Administrateur
password: Key11ogger
optReferrals: false # Optional
useSsl: true # Enable SSL negotiation. Optional
useStartTls: true # Enable TLS negotiation. Optional
user:
baseDn: dc=talan, dc=local
filter: (&(ObjectClass=Person))
attributes: # Specify ldap attributes mapping [ldap attribute, user object method]

{ ldap_attr: uid, user_method: setUsername } # Default

and my security.yml

security:
providers:
chain_provider:
chain:
providers: [fos_userbundle, fr3d_ldapbundle]
fos_userbundle:
id: fos_user.user_manager
fr3d_ldapbundle:
id: fr3d_ldap.security.user.provider
firewalls:
main:
pattern: ^/
fr3d_ldap: ~
form_login:
provider: chain_provider
always_use_default_target_path: true
default_target_path: /
logout: true
anonymous: true

please help, thank you !

@Maks3w
Copy link
Owner

Maks3w commented Oct 31, 2012

Please edit your message and add markup for format the config as YAML

```yaml
 <paste here>
```

Anyway it's not possible to have useSsl and useStartTls enable at the same time, you must choose one of them

@symfony24
Copy link
Author

no it's not enabled.

security.yml

security:
  providers:
        chain_provider:
          chain:
            providers: [fos_userbundle, fr3d_ldapbundle]

        fos_userbundle:
            id: fos_user.user_manager
        fr3d_ldapbundle:
            id: fr3d_ldap.security.user.provider
  firewalls:
    main:
      pattern:    ^/
      fr3d_ldap:  ~
      form_login:
          provider: chain_provider
          always_use_default_target_path: true
          default_target_path: /
      logout:     true
      anonymous:  true

and config.yml

fr3d_ldap:
    client:
        host:         192.168.8.95
        port:         389    # Optional
#       version:        3    # Optional
        username:     cn=Administrateur
        password:     Key11ogger
#       optReferrals: false  # Optional
#        useSsl:       true   # Enable SSL negotiation. Optional
#       useStartTls:  true   # Enable TLS negotiation. Optional
    user:
        baseDn:  dc=talan, dc=local
        filter: (&(ObjectClass=Person))
        attributes:          # Specify ldap attributes mapping [ldap attribute, user object method]

           - { ldap_attr: uid,  user_method: setUsername } # Default
#           - { ldap_attr: cn,   user_method: setName }     # Optional
#           - { ldap_attr: ...,  user_method: ... }         # Optional
           - { ldap_attr: mail, user_method: setEmail } 

and my User.php

<?php
// src/Acme/UserBundle/Entity/User.php

namespace Talan\VpnBundle\Entity;

use FR3D\LdapBundle\Model\LdapUserInterface;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser implements LdapUserInterface
{

    /**
   * @var integer $id
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $id;
/**
   * Ldap Object Distinguished Name
   * @var string $dn
   */
  protected $dn;
  /**
   * Get id
   *
   * @return integer
   */
  public function getId()
  {
      return $this->id;
  }



    public function __construct()
    {
        parent::__construct();
        // your own logic


    }

    /**
     * {@inheritDoc}
     */
    public function getDn() {
      return $this->dn;  
    }


    /**
     * {@inheritDoc}
     */
    public function setDn($dn) {
        $this->dn = $dn;
    }

}

@Maks3w
Copy link
Owner

Maks3w commented Oct 31, 2012

username should be the full DN or just the username value

@symfony24
Copy link
Author

great authentication work fine thx to this topic #10
, now i need to manage authorization
For example,
if the user exists within the LDAP group named "Admin", the provided LdapUser object will have the "ROLE_LDAP_ADMIN" role.
what shall i do ?

@Maks3w
Copy link
Owner

Maks3w commented Nov 1, 2012

At this moment I don't provide support for roles but seems that @jkostrz applied a patch for it https://github.com/jkostrz/FR3DLdapBundle

@Maks3w Maks3w closed this as completed Jul 9, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants