Riddle me this (PHP Error: No property on object)

Posted 3 months ago by Jaytee

Long time no speak to some of you. Okay, so we use LDAP for authentication at work on our internal server (intranet). I've come across an issue on a new application for one certain user. It's mind boggling shit.

// Active Directory. Does a search for the user's usercode. Gets this from $_SERVER['REMOTE_USER'];

e.g: REMOTE_USER = 'CORP\jth181';

// We do an explode on the remote user, get the usercode (the bit after CORP\); This all works fine

// This also works fine. Returns a user object
$adUser = $ad->getMyDetails();

Above is a basic rundown on how we get a user's credentials etc.

Now, if i run dd() on the $adUser, it's fine, we have a property called usercode. Typical stuff, we use it all the time by passing it through to User::firstOrNew(['usercode' => $adUser->usercode])

Here's where things get fucked up. There is one user who has a completely different structure to her usercode. Usually it's a alpha numeric string, but her's is firstname.lastname

When we do $adUser->usercode on this particular user, PHP throws an error saying the usercode property doesn't exist on the object. Try cast it to an array, and it complains about the index. Weird as fuck.

But yet, we can actually dd() on the object and dd() on $adUser->usercode, but the second we try call it, nope, doesn't work. Yep it's public etc.

I should explain, hers is the only usercode that is different. We have 50,000 employees in the company, with about 2-3000 of those that use this authentication method. I can also set a new property on the object and pass it the usercode (e.g: we manipulated it, by removing the dot out of the usercode), but the second we call that property, it complains too.

Any ideas?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.