LdapSync doesn't create Models

Get help from the community here.

Moderator: Developers

michaeled
Posts: 86
Joined: Wed May 09, 2012 2:00 pm

LdapSync doesn't create Models

Postby michaeled » Tue Oct 18, 2016 2:10 pm

Hi,

I'v developped a php script that create user in LDAP and then synchronise it with GroupOffice.

The creation, the user is well add to the groups but the models (calendars for example) is not created still the user connect himself.

I need to share the user calendar just after the user is created, so the models have to be created.

Do you know how to do this ?

This is my code :
GO::session()->runAsRoot();
$la = new \GO\Ldapauth\Authenticator();
$ldapConn = \GO\Base\Ldap\Connection::getDefault();
$result = $ldapConn->search(GO::config()->ldap_peopledn,'uid='.$uid);
$record = $result->fetch();
$user = $la->syncUserWithLdapRecord($record);
$user->save();
$user->checkDefaultModels();
$dnGroupe="cn=GROUP,".$config['ldap_groupsdn'];
$group = \GO\Base\Model\Group::model()->findSingleByAttribute('name', 'GROUP');
$group->addUser($user->id);
ldap_mod_add($ds,$dnGroupe,$membre_info);
$user = $la->syncUserWithLdapRecord($record);
$user->save();


Regards,

Michael
mschering
Site Admin
Site Admin
Posts: 8154
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: LdapSync doesn't create Models

Postby mschering » Mon Nov 14, 2016 10:03 am

Try:

Code: Select all

$calendar = \GO\Calendar\Model\Calendar::getDefault($user);

$calendar->getAcl()->addGroup(2);//everyone
Best regards,

Merijn Schering
Intermesh
michaeled
Posts: 86
Joined: Wed May 09, 2012 2:00 pm

Re: LdapSync doesn't create Models

Postby michaeled » Wed Nov 23, 2016 10:50 am

mschering wrote:Try:

Code: Select all

$calendar = \GO\Calendar\Model\Calendar::getDefault($user);

$calendar->getAcl()->addGroup(2);//everyone


Hi,

I add the first line and I obtain this error :

Code: Select all

PHP Fatal error:  Using $this when not in object context in /var/www/gedeon/go/base/model/AbstractUserDefaultModel.php on line 101




This is the object I send in $user :

Code: Select all

GO\Base\Model\User Object ( [generatedRandomPassword] => [passwordConfirm] => [skip_contact_update] => [_unencryptedPassword:GO\Base\Model\User:private] => [contact_id] => [_completeDateFormat:GO\Base\Model\User:private] => [_attributeLabels:GO\Base\Db\ActiveRecord:private] => [_forceSave:GO\Base\Db\ActiveRecord:private] => [insertDelayed:protected] => [loadingFromDatabase:protected] => [_customfieldsRecord:GO\Base\Db\ActiveRecord:private] => GO\Users\Customfields\Model\User Object ( [_rawPostedAttributes:protected] => [_attributeLabels:GO\Base\Db\ActiveRecord:private] => [_forceSave:GO\Base\Db\ActiveRecord:private] => [insertDelayed:protected] => [loadingFromDatabase:protected] => [_customfieldsRecord:GO\Base\Db\ActiveRecord:private] => [_acl:GO\Base\Db\ActiveRecord:private] => [overwriteAcl:protected] => [_relatedCache:GO\Base\Db\ActiveRecord:private] => [_joinRelationAttr:GO\Base\Db\ActiveRecord:private] => [_attributes:protected] => Array ( [model_id] => 1885 ) [_modifiedAttributes:GO\Base\Db\ActiveRecord:private] => Array ( ) [_debugSql:GO\Base\Db\ActiveRecord:private] => [_filesFolder:GO\Base\Db\ActiveRecord:private] => [columns:protected] => Array ( [model_id] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => int [null] => ) ) [_new:GO\Base\Db\ActiveRecord:private] => 1 [_isStaticModel:GO\Base\Db\ActiveRecord:private] => [_pdo:GO\Base\Db\ActiveRecord:private] => [_permissionLevel:GO\Base\Db\ActiveRecord:private] => [_acl_id:GO\Base\Db\ActiveRecord:private] => [useSqlCalcFoundRows:GO\Base\Db\ActiveRecord:private] => 1 [_runTimeValidationRules:GO\Base\Db\ActiveRecord:private] => Array ( ) [_validationErrors:protected] => Array ( ) ) [_acl:GO\Base\Db\ActiveRecord:private] => [overwriteAcl:protected] => [_relatedCache:GO\Base\Db\ActiveRecord:private] => [_joinRelationAttr:GO\Base\Db\ActiveRecord:private] => [_attributes:protected] => Array ( [id] => 1885 [username] => c.titi [password] => $5$73Z5p0b/vth1qC5q$L9KRf0RAMbuCRJ3jjr5d8EsQr5XRvW5Pulp41gskIY5 [digest] => 0b063b601da32ca90a1f037cbe550768 [enabled] => 1 [first_name] => Charles [middle_name] => [last_name] => TITI [email] => dfgdfg@dfg.com [acl_id] => 17539 [date_format] => dmY [date_separator] => - [time_format] => G:i [thousands_separator] => . [decimal_separator] => , [currency] => € [logins] => 0 [lastlogin] => 0 [ctime] => 1479900418 [max_rows_list] => 30 [timezone] => Europe/Paris [start_module] => summary [language] => fr [theme] => Group-Office [first_weekday] => 1 [sort_name] => first_name [mtime] => 1479900418 [mute_sound] => 0 [mute_reminder_sound] => 0 [mute_new_mail_sound] => 0 [show_smilies] => 1 [auto_punctuation] => 0 [list_separator] => ; [text_separator] => " [files_folder_id] => 0 [disk_usage] => 0 [disk_quota] => 1000 [mail_reminders] => 0 [popup_reminders] => 0 [password_type] => crypt [muser_id] => 1 [holidayset] => fr [sort_email_addresses_by_time] => 0 [no_reminders] => 0 ) [_modifiedAttributes:GO\Base\Db\ActiveRecord:private] => Array ( ) [_debugSql:GO\Base\Db\ActiveRecord:private] => [_filesFolder:GO\Base\Db\ActiveRecord:private] => [columns:protected] => Array ( [id] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => [dbtype] => int [null] => ) [username] => Array ( [type] => 2 [required] => 1 [length] => 50 [gotype] => textfield [default] => [dbtype] => varchar [null] => [regex] => /^[A-Za-z0-9_\-\.\@]*$/ ) [password] => Array ( [type] => 2 [required] => 1 [length] => 255 [gotype] => textfield [default] => [dbtype] => varchar [null] => ) [digest] => Array ( [type] => 2 [required] => [length] => 255 [gotype] => textfield [default] => [dbtype] => varchar [null] => ) [enabled] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 1 [dbtype] => tinyint [null] => ) [first_name] => Array ( [type] => 2 [required] => 1 [length] => 50 [gotype] => textfield [default] => [dbtype] => varchar [null] => ) [middle_name] => Array ( [type] => 2 [required] => [length] => 50 [gotype] => textfield [default] => [dbtype] => varchar [null] => ) [last_name] => Array ( [type] => 2 [required] => 1 [length] => 100 [gotype] => textfield [default] => [dbtype] => varchar [null] => ) [email] => Array ( [type] => 2 [required] => 1 [length] => 100 [gotype] => textfield [default] => [dbtype] => varchar [null] => [regex] => /^[a-z0-9\._\-+\&\']+@[a-z0-9\.\-_]+\.[a-z]{2,100}$/i ) [acl_id] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => int [null] => ) [date_format] => Array ( [type] => 2 [required] => [length] => 20 [gotype] => textfield [default] => dmY [dbtype] => varchar [null] => ) [date_separator] => Array ( [type] => 2 [required] => [length] => 1 [gotype] => textfield [default] => - [dbtype] => char [null] => ) [time_format] => Array ( [type] => 2 [required] => [length] => 10 [gotype] => textfield [default] => G:i [dbtype] => varchar [null] => ) [thousands_separator] => Array ( [type] => 2 [required] => [length] => 1 [gotype] => textfield [default] => . [dbtype] => char [null] => ) [decimal_separator] => Array ( [type] => 2 [required] => [length] => 1 [gotype] => textfield [default] => , [dbtype] => char [null] => ) [currency] => Array ( [type] => 2 [required] => [length] => 3 [gotype] => textfield [default] => [dbtype] => char [null] => ) [logins] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => int [null] => ) [lastlogin] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => unixtimestamp [default] => 0 [dbtype] => int [null] => ) [ctime] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => unixtimestamp [default] => 0 [dbtype] => int [null] => ) [max_rows_list] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 20 [dbtype] => int [null] => ) [timezone] => Array ( [type] => 2 [required] => 1 [length] => 50 [gotype] => textfield [default] => Europe/Amsterdam [dbtype] => varchar [null] => ) [start_module] => Array ( [type] => 2 [required] => [length] => 50 [gotype] => textfield [default] => summary [dbtype] => varchar [null] => ) [language] => Array ( [type] => 2 [required] => [length] => 20 [gotype] => textfield [default] => en [dbtype] => varchar [null] => ) [theme] => Array ( [type] => 2 [required] => [length] => 20 [gotype] => textfield [default] => Default [dbtype] => varchar [null] => ) [first_weekday] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => tinyint [null] => ) [sort_name] => Array ( [type] => 2 [required] => [length] => 20 [gotype] => textfield [default] => first_name [dbtype] => varchar [null] => ) [mtime] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => unixtimestamp [default] => 0 [dbtype] => int [null] => ) [mute_sound] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [mute_reminder_sound] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [mute_new_mail_sound] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [show_smilies] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 1 [dbtype] => tinyint [null] => ) [auto_punctuation] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [list_separator] => Array ( [type] => 2 [required] => [length] => 3 [gotype] => textfield [default] => ; [dbtype] => char [null] => ) [text_separator] => Array ( [type] => 2 [required] => [length] => 3 [gotype] => textfield [default] => " [dbtype] => char [null] => ) [files_folder_id] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => int [null] => ) [disk_usage] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => bigint [null] => ) [disk_quota] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => number [default] => [dbtype] => bigint [null] => 1 [decimals] => 0 ) [mail_reminders] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [popup_reminders] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [password_type] => Array ( [type] => 2 [required] => [length] => 20 [gotype] => textfield [default] => crypt [dbtype] => varchar [null] => ) [muser_id] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => [default] => 0 [dbtype] => int [null] => ) [holidayset] => Array ( [type] => 2 [required] => [length] => 10 [gotype] => textfield [default] => [dbtype] => varchar [null] => 1 ) [sort_email_addresses_by_time] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) [no_reminders] => Array ( [type] => 1 [required] => [length] => 0 [gotype] => boolean [default] => 0 [dbtype] => tinyint [null] => ) ) [_new:GO\Base\Db\ActiveRecord:private] => [_isStaticModel:GO\Base\Db\ActiveRecord:private] => [_pdo:GO\Base\Db\ActiveRecord:private] => [_permissionLevel:GO\Base\Db\ActiveRecord:private] => 50 [_acl_id:GO\Base\Db\ActiveRecord:private] => 17539 [useSqlCalcFoundRows:GO\Base\Db\ActiveRecord:private] => 1 [_runTimeValidationRules:GO\Base\Db\ActiveRecord:private] => Array ( ) [_validationErrors:protected] => Array ( ) )

Return to “General help”

Who is online

Users browsing this forum: No registered users and 5 guests

cron