Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on creating new entry #26

Open
chri2 opened this issue Oct 23, 2023 · 2 comments
Open

error on creating new entry #26

chri2 opened this issue Oct 23, 2023 · 2 comments
Labels

Comments

@chri2
Copy link

chri2 commented Oct 23, 2023

Describe the bug

When creating a new entry phpldapadmin shows an error.

Unrecognized error number: 8192: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

Might be associated to this issue: leenooks/phpLDAPadmin#237

Context

  • Hardware: Virtualbox VM
  • YunoHost version: 11.2.5
  • I have access to my server: all
  • Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: yes
    • If yes, please explain: Testing environment, slapd tweaked to allow full access
  • Using, or trying to install package version/branch: phpLDAPadmin 1.2.6.6~ynh4

Steps to reproduce

  • adapt the slapd configuration to give write permission to a user able to login
  • add an entry - in my case

objectClass: inetOrgPerson, mailAccount, userPermissionYnh
ou=alias
rdn=cn

Expected behavior

show the confirmation page after hitting the "create object" button

Logs

2023-10-23_08-40-17-832012743

@tituspijean
Copy link
Member

tituspijean commented Oct 23, 2023

It's indeed most likely an upstream issue.

I guess you can apply the other user's bugfix manually.

@chri2
Copy link
Author

chri2 commented Oct 23, 2023

Works like this:

root@yt:/var/www/phpldapadmin/lib# diff PageRender.php.orig PageRender.php
918,924c918,929
< 	protected function getAutoPostPasswordAttribute($attribute,$i) {
< 		# If the password is already encoded, then we'll return
< 		if (preg_match('/^\{.+\}.+/',$attribute->getValue($i)))
< 			return;
< 
< 		$attribute->setPostValue(array('function'=>'PasswordEncrypt','args'=>sprintf('%%enc%%;%%%s%%',$attribute->getName())));
< 		$this->get('Post',$attribute,$i);
---
> 	protected function getAutoPostPasswordAttribute($attribute, $i) {
> 	                // Extract the string data from the PasswordAttribute object
> 	                $attributeString = $attribute->getValue(0);  // Using index 0 as an example
> 	
> 	                // If the attribute is null or already encoded, return early
> 	                if ($attributeString === null || preg_match('/^\{.+\}.+/', $attributeString)) {
> 	                return;
> 	        }
> 	
> 	        // Otherwise, proceed with password encryption and post
> 	        $attribute->setPostValue(array('function'=>'PasswordEncrypt','args'=>sprintf('%%enc%%;%%%s%%', $attribute->getName())));
> 	        $this->get('Post', $attribute, $i);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants