When a user inserts its secret code the account creation fail.

The problem is in _ldapprov_create_user. variable_get('ldapprov_profile_first', '') and variable_get('ldapprov_profile_last', '') are not valid keys of edit array when ldapprov_profile is TRUE (the profile module, ldapprov_profile_first and ldapprov_profile_last is set to a valid field name).

I attach a patch to solve this problem.

CommentFileSizeAuthor
ldapprov.module.patch881 bytesjesustorres

Comments

ckng’s picture

You should set the appropriate ldap fields mapping under Registration form of ldap_provisioning.
I do not face problem on this one and the code looks correct to me.

jesustorres’s picture

I did set the fields realname and surname as first_name and last_name but the elements 'realname' and 'surname' are not defined in the edit array. It happens because that elements are not set in the caller function. However, that function set the 'first_name' and 'last_name' elements.

miglius’s picture

jmtorres,

The $edit['first_name'] and $edit['last_name'] should be used only when profile module is disabled, "Use profile fields in the registration form" is not checked or "Profile first name:" & "Profile last name:" are not configured. Otherwise the configured "Profile first name:" & "Profile last name:" are used as the key for the first and last names.

If you don't get it working, can you post snapshots of the configuration form?

jesustorres’s picture

I have downloaded and tried the module again but it does not create the new user. If I enable debugging, I can see the next LDIF entries:

dn: uid=prueba,ou=People,dc=gulic,dc=org
objectClass: topobjectClass

I will try to discover where is the problem.

jesustorres’s picture

After do some test checking the value of some variables, I think my patch is fine. I will try to tell you because I think it. If is hard to you understand my english, I'm sorry.

I have configured the module to use the profile fields in the registry form, that is "Use profile fields in the registration form" is checked and "Profile first name:" & "Profile last name:" are configured. I have been able to see that the function invoked when the registration form is submitted is ldapprov_register_submit(9. That function insert in the db all the information need to create the new user account, including the firstname and lastname.

In the same manner, the function invoked when the validation form is submitted is _ldapprov_validate_submit(). That function retrieve all the information stored by ldapprov_register_submit in the database and, if approval is not needed, call _ldapprov_create_user() function. As you can see in lines 1427-1428:

1425 $edit['rid'] = $row->rid;
1426 $edit['username'] = $row->name;
1427 $edit['first_name'] = $row->first_name;
1428 $edit['last_name'] = (!empty($row->last_name)) ? $row->last_name : $row->name;
1429 $edit['mail'] = $row->mail;

The firstname and lastname are saved in $edit['first_name'] and $edit['last_name'] before call _ldapprov_create_user.

1430 $new_user = _ldapprov_create_user($edit);

I think, even if profile module is enable, the firstname and lastname are allways stored in $edit['first_name'] and $edit['last_name']. And never in $edit[variable_get('ldapprov_profile_first', '')] & $edit[variable_get('ldapprov_profile_last', '')].

Am I wrong?

miglius’s picture

The lines 1427 and 1428 are for the case when profile is not used. When profile is used $edit[variable_get('ldapprov_profile_first', '')] & $edit[variable_get('ldapprov_profile_last', '')] are defined in line 1422 since those are saved as a serialized data in the database.

I think I know why you're getting problems. The profile name should be in the form profile_your_string. If you don't use profile_ prefix it is not saved as a serialized data, as can be seen in line 1217.

jesustorres’s picture

wohhhhh!!! I was thinking this afternoon ask to you why do you not serialize the profile field and insert them in the database... You have reason. The problem was the profile_ prefix. It works fine now. Thank you.

miglius’s picture

Assigned: Unassigned » miglius
Status: Active » Fixed

Cool. I will change the field description to emphasize the profile_ prefix.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.