Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
ldap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
ldap
Commits
8d66ec30
Commit
8d66ec30
authored
Jun 18, 2020
by
surville
Browse files
Options
Downloads
Patches
Plain Diff
Gestion des attributs liés au mot de passe
parent
80f41192
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenLdap/Entity/Base/People.php
+91
-8
91 additions, 8 deletions
src/UnicaenLdap/Entity/Base/People.php
src/UnicaenLdap/Entity/People.php
+37
-0
37 additions, 0 deletions
src/UnicaenLdap/Entity/People.php
with
128 additions
and
8 deletions
src/UnicaenLdap/Entity/Base/People.php
+
91
−
8
View file @
8d66ec30
...
@@ -7,6 +7,7 @@ use UnicaenLdap\Entity\Entity;
...
@@ -7,6 +7,7 @@ use UnicaenLdap\Entity\Entity;
use
UnicaenLdap\Entity\People
as
PeopleEntity
;
use
UnicaenLdap\Entity\People
as
PeopleEntity
;
use
UnicaenLdap\Entity\Structure
as
StructureEntity
;
use
UnicaenLdap\Entity\Structure
as
StructureEntity
;
use
UnicaenLdap\Exception
;
use
UnicaenLdap\Exception
;
use
Zend\Ldap\Attribute
;
use
Zend\Ldap\Dn
;
use
Zend\Ldap\Dn
;
use
Zend\Ldap\Exception\LdapException
;
use
Zend\Ldap\Exception\LdapException
;
...
@@ -71,10 +72,12 @@ class People extends Entity
...
@@ -71,10 +72,12 @@ class People extends Entity
'loginShell'
,
'loginShell'
,
'mail'
,
'mail'
,
'mobile'
,
'mobile'
,
'ntPassword'
,
'pager'
,
'pager'
,
'postalAddress'
,
'postalAddress'
,
'preferredLanguage'
,
'preferredLanguage'
,
'rid'
,
'rid'
,
'sambaNTPassword'
,
'sambaSID'
,
'sambaSID'
,
'schacDateOfBirth'
,
'schacDateOfBirth'
,
'schacExpiryDate'
,
'schacExpiryDate'
,
...
@@ -122,12 +125,14 @@ class People extends Entity
...
@@ -122,12 +125,14 @@ class People extends Entity
'ucbnServicePapercut'
,
'ucbnServicePapercut'
,
'ucbnSiteLocalisation'
,
'ucbnSiteLocalisation'
,
'ucbnSousStructure'
,
'ucbnSousStructure'
,
'ucbnSquidHash'
,
'ucbnStatus'
,
'ucbnStatus'
,
'ucbnStructureRecherche'
,
'ucbnStructureRecherche'
,
'uidNumber'
,
'unicaenMonEtupass'
,
'unicaenMonEtupass'
,
'unicaenTermsOfUse'
,
'unicaenTermsOfUse'
,
'userCertificate'
,
'userCertificate'
,
'u
idNumber
'
,
'u
serPassword
'
,
];
];
/**
/**
...
@@ -153,9 +158,16 @@ class People extends Entity
...
@@ -153,9 +158,16 @@ class People extends Entity
'eduPersonPrimaryAffiliation'
,
'eduPersonPrimaryAffiliation'
,
'eduPersonPrimaryOrgUnitDN'
,
'eduPersonPrimaryOrgUnitDN'
,
'eduPersonPrincipalName'
,
'eduPersonPrincipalName'
,
'gidNumber'
,
'givenName'
,
'givenName'
,
'homeDirectory'
,
'leoCode'
,
'leoCode'
,
'loginShell'
,
'ntPassword'
,
'preferredLanguage'
,
'preferredLanguage'
,
'rid'
,
'sambaNTPassword'
,
'sambaSID'
,
'schacDateOfBirth'
,
'schacDateOfBirth'
,
'schacExpiryDate'
,
'schacExpiryDate'
,
'sexe'
,
'sexe'
,
...
@@ -167,12 +179,9 @@ class People extends Entity
...
@@ -167,12 +179,9 @@ class People extends Entity
'supannEtuId'
,
'supannEtuId'
,
'supannListeRouge'
,
'supannListeRouge'
,
'telephoneNumber'
,
'telephoneNumber'
,
'rid'
,
'ucbnSquidHash'
,
'sambaSID'
,
'uidNumber'
,
'uidNumber'
,
'gidNumber'
,
'userPassword'
,
'loginShell'
,
'homeDirectory'
];
];
/**
/**
...
@@ -1825,7 +1834,6 @@ class People extends Entity
...
@@ -1825,7 +1834,6 @@ class People extends Entity
/**
/**
* Attribut Ldap "loginShell"
* Attribut Ldap "loginShell"
* @todo tester le format
*
*
* @param array|string|null $value
* @param array|string|null $value
* @param bool $append
* @param bool $append
...
@@ -1843,7 +1851,6 @@ class People extends Entity
...
@@ -1843,7 +1851,6 @@ class People extends Entity
/**
/**
* Attribut Ldap "homeDirectory"
* Attribut Ldap "homeDirectory"
* @todo tester le format
*
*
* @param array|string|null $value
* @param array|string|null $value
* @param bool $append
* @param bool $append
...
@@ -1859,6 +1866,82 @@ class People extends Entity
...
@@ -1859,6 +1866,82 @@ class People extends Entity
return
$this
;
return
$this
;
}
}
/**
* Attribut Ldap "userPassword"
*
* @param string $value
* @return self
* @throws LdapException
*/
public
function
setUserPassword
(
string
$value
)
{
$this
->
getNode
()
->
setPasswordAttribute
(
$value
,
Attribute
::
PASSWORD_HASH_SHA
,
'userPassword'
);
return
$this
;
}
/**
* Attribut Ldap "ntPassword"
*
* @param string $value
* @return $this
* @throws Exception
* @throws LdapException
*/
public
function
setNtPassword
(
string
$value
)
{
$uni
=
''
;
$value
=
(
string
)
$value
;
for
(
$i
=
0
;
$i
<
strlen
(
$value
);
$i
++
)
{
$a
=
ord
(
$value
{
$i
})
<<
8
;
$uni
.
=
sprintf
(
'%X'
,
$a
);
}
$nthash
=
hash
(
"md4"
,
pack
(
'H*'
,
$uni
),
true
);
$this
->
appendOrNot
(
'ntPassword'
,
strtoupper
(
bin2hex
(
$nthash
)),
false
);
return
$this
;
}
/**
* Attribut Ldap "sambaNTPassword"
* @see setNtPassword
*
* @param string $value
* @return $this
* @throws Exception
* @throws LdapException
*/
public
function
setSambaNTPassword
(
string
$value
)
{
$uni
=
''
;
$value
=
(
string
)
$value
;
for
(
$i
=
0
;
$i
<
strlen
(
$value
);
$i
++
)
{
$a
=
ord
(
$value
{
$i
})
<<
8
;
$uni
.
=
sprintf
(
'%X'
,
$a
);
}
$nthash
=
hash
(
"md4"
,
pack
(
'H*'
,
$uni
),
true
);
$this
->
appendOrNot
(
'sambaNTPassword'
,
strtoupper
(
bin2hex
(
$nthash
)),
false
);
return
$this
;
}
/**
* Attribut Ldap "ucbnSquidHash"
*
* @param string $value
* @param bool $append
* @return $this
* @throws Exception
* @throws LdapException
*/
public
function
setUcbnSquidHash
(
string
$value
)
{
$value
=
"Unicaen:"
.
md5
(
sprintf
(
'%s:Unicaen:%s'
,
$this
->
get
(
'supannAliasLogin'
),
$value
));
$this
->
appendOrNot
(
'ucbnSquidHash'
,
$value
,
false
);
return
$this
;
}
/**
/**
* Retourne les structures auxquelles appartiennent la personne
* Retourne les structures auxquelles appartiennent la personne
*
*
...
...
This diff is collapsed.
Click to expand it.
src/UnicaenLdap/Entity/People.php
+
37
−
0
View file @
8d66ec30
...
@@ -93,6 +93,25 @@ class People extends BasePeople
...
@@ -93,6 +93,25 @@ class People extends BasePeople
return
(
$prenomDabord
?
$prenom
.
' '
.
$nom
:
$nom
.
' '
.
$prenom
)
.
$civilite
;
return
(
$prenomDabord
?
$prenom
.
' '
.
$nom
:
$nom
.
' '
.
$prenom
)
.
$civilite
;
}
}
/**
* Retourne l'identifiant Octopus de l'individu
*
* @return string|null
*/
public
function
getOctopusId
()
{
$attributeValues
=
$this
->
preFormat
(
$this
->
supannRefId
);
$label
=
$this
->
getLabel
(
'OCTOPUS'
,
'ID'
);
$value
=
array_filter
(
$attributeValues
,
function
(
$v
)
use
(
$label
)
{
return
preg_match
(
"/^
$label
(?<identifiant>.+)$/"
,
$v
);
});
return
!
empty
(
$value
)
?
str_replace
(
$label
,
''
,
array_values
(
$value
)[
0
])
:
null
;
}
/**
/**
* Retourne le léocode associé à l'individu
* Retourne le léocode associé à l'individu
*
*
...
@@ -234,6 +253,24 @@ class People extends BasePeople
...
@@ -234,6 +253,24 @@ class People extends BasePeople
return
$structureService
->
getBy
(
$dn
,
'dn'
);
return
$structureService
->
getBy
(
$dn
,
'dn'
);
}
}
/**
* Modifie l'ensemble des attributs liés au mot de passe
*
* @param string $value
* @return $this
* @throws \UnicaenLdap\Exception
* @throws \Zend\Ldap\Exception\LdapException
*/
public
function
setPassword
(
string
$value
)
{
parent
::
setUserPassword
(
$value
);
parent
::
setNtPassword
(
$value
);
parent
::
setSambaNTPassword
(
$value
);
parent
::
setUcbnSquidHash
(
$value
);
return
$this
;
}
/**
/**
* Retourne true si l'argument est au format "supannRoleEntite".
* Retourne true si l'argument est au format "supannRoleEntite".
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment