Closed paulb-smartit closed 2 years ago
Hi @paulb-opusvl,
Can you confirm if this occurs from finding the OrganizationalUnit
?
Try executing only OrganizationalUnit::findOrFail($dn)
to see if this still occurs, and we can go from there 👍
It's definitely happening at the point of ->save()
as I ca ndo a dd
before and get this:
App\Ldap\User {#1348
+exists: false
+wasRecentlyCreated: false
+wasRecentlyRenamed: false
#dn: null
#in: "ou=staff,ou=people,dc=xxx"
#connection: null
#guidKey: "entryuuid"
#modifications: []
#original: []
#attributes: array:3 [
"objectclasses" => array:3 [
0 => array:1 [
"objectclass" => "top"
]
1 => array:1 [
"objectclass" => "person"
]
2 => array:1 [
"objectclass" => "organizationalperson"
]
]
"sn" => array:1 [
0 => "Coyote"
]
"cn" => array:1 [
0 => "Whiley Coyote"
]
]
#dates: []
#casts: []
#appends: []
#dateFormat: null
#defaultDates: array:2 [
"createtimestamp" => "ldap"
"modifytimestamp" => "ldap"
]
#hidden: array:1 [
0 => "userPassword"
]
#visible: array:6 [
0 => "cn"
1 => "mail"
2 => "sn"
3 => "givenName"
4 => "initials"
5 => "uid"
]
#passwordAttribute: "userpassword"
#passwordHashMethod: "ssha"
Ok thanks for posting that. I see what may be going on here -- the objectclasses
are formatted incorrectly. They must only be values, not key => value
pairs.
You are also setting them when they do not need to be set as an attribute. The static object classes are inserted into the LDAP record during creation automatically.
Remove $ldapUser->objectclasses = $classes
and then try creation again 👍
I can close this.
Not for the first time, I embarrass myself with something that once I figure it out becomes obvious.
The whole objectClasses
was a red herring. What the error meant was that I was trying to use an attribute from a schema that didn't support it. My 3 object classes don't support my default rdn
- uid
. For that I had to add posixAccount
and add in a lot more mandatory attributes.
Once I did that, the model saves into LDAP.
$ou = OrganizationalUnit::findOrFail($user['ou'].$base_dn);
$ldapUser = (new User)->inside($ou);
$ldapUser->uid = $user['uid'];
$ldapUser->sn = $user['sn'];
$ldapUser->cn = sprintf("%s %s", $user['givenname'], $user['sn']);
$ldapUser->setDn($user['dn']);
$ldapUser->userPassword = 'RoadRunner1234567890';
$ldapUser->uidnumber = 999;
$ldapUser->gidnumber = 999;
$ldapUser->homedirectory = "/dev/null";
$ldapUser->save();
Thanks for a great product.
Ah it happens to all of us haha, I'm so glad you've resolved this issue and posted the solution.
Always happy to help! Take care.
Environment:
Describe the bug:
When I try to save a new user I get a segfault. It either kills my artisan server or nginx instance.
This is the code I'm using for saving the user. I'm passing in an array
$user[]
with the attributes required. I removed all attributes other than the basic.I had to populate
objectClasses
or I get a class violation.It never gets to the exception or return.
I see in the ldap logs that it searches for the
ou
then boom.