@@ 181-197 (lines=17) @@ | ||
178 | * Create the user in LDAP, provided this configuration is enabled |
|
179 | * and a username was passed to a new Member record. |
|
180 | */ |
|
181 | public function onBeforeWrite() |
|
182 | { |
|
183 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
184 | return; |
|
185 | } |
|
186 | ||
187 | $service = Injector::inst()->get('SilverStripe\\ActiveDirectory\\Services\\LDAPService'); |
|
188 | if (!$service->enabled() |
|
189 | || !$this->owner->config()->create_users_in_ldap |
|
190 | || !$this->owner->Username |
|
191 | || $this->owner->GUID |
|
192 | ) { |
|
193 | return; |
|
194 | } |
|
195 | ||
196 | $service->createLDAPUser($this->owner); |
|
197 | } |
|
198 | ||
199 | public function onAfterWrite() |
|
200 | { |
|
@@ 216-232 (lines=17) @@ | ||
213 | $this->sync(); |
|
214 | } |
|
215 | ||
216 | public function onAfterDelete() |
|
217 | { |
|
218 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
219 | return; |
|
220 | } |
|
221 | ||
222 | $service = Injector::inst()->get('SilverStripe\\ActiveDirectory\\Services\\LDAPService'); |
|
223 | if ( |
|
224 | !$service->enabled() || |
|
225 | !$this->owner->config()->delete_users_in_ldap || |
|
226 | !$this->owner->GUID |
|
227 | ) { |
|
228 | return; |
|
229 | } |
|
230 | ||
231 | $service->deleteLDAPMember($this->owner); |
|
232 | } |
|
233 | ||
234 | /** |
|
235 | * Write DataObject without triggering this extension's hooks. |