Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration for creating groups in SilverStripe to sync to LDAP #3

Open
robbieaverill opened this issue Oct 3, 2017 · 0 comments

Comments

@robbieaverill
Copy link
Contributor

The LDAPService has a createLDAPGroup(Group $group) method, however it's not connected via the LDAPGroupExtension at present.

It would be nice if this were possible, via configuration or default, in a similar way as LDAPMemberExtension uses LDAPService::createLDAPUser to sync members to LDAP when created in SilverStripe.

In a quick discussion with @mateusz he highlighted that it's potentially dangerous and risks an infinite loop between writing SS -> LDAP and syncing back again, but has provided some user code that can be used to do this:

$dn = sprintf('CN=%s,%s', $groupCode, \Config::inst()->get('LDAPService', 'new_groups_dn'));
$data = $this->ldapService->getGroupByDN($dn);
if (!empty($data['objectguid'])) {
    if (is_callable($logFn)) {
        $logFn(sprintf('* Using existing LDAP group "%s"', $groupCode));
    }
    $group->GUID = $data['objectguid'];
} else {
    if (is_callable($logFn)) {
        $logFn(sprintf('* Creating new LDAP group "%s"', $groupCode));
    }
    $group->Title = $groupCode;
    $this->ldapService->createLDAPGroup($group);
}

Will need further thought and discussion before implementation.

robbieaverill pushed a commit to creative-commoners/silverstripe-ldap that referenced this issue Jan 15, 2019
…group-mappings

Fix group mappings for removed Groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants