summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2a155c4)
raw | patch | inline | side by side (parent: 2a155c4)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 1 Sep 2009 09:47:35 +0000 (09:47 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 1 Sep 2009 09:47:35 +0000 (09:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14185 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/contrib/gosa.conf.5 | patch | blob | history | |
gosa-core/include/class_plugin.inc | patch | blob | history | |
gosa-core/plugins/personal/generic/class_user.inc | patch | blob | history |
index ceacd8a0054663385ce031ecaefcc661687d0420..d1718e209af0d72777a40c0426fcae1aa9a74d72 100644 (file)
.I personalTitleInDN.
.PP
+.B accountRDN
+.I pattern
+.PP
+The
+.I accountRDN
+option tells GOsa to use a placeholder pattern for generating account
+RDNs. A pattern can include attribute names prefaced by a % and normal
+text:
+.nf
+accountRDN="cn=%sn %givenName"
+.fi
+This will generate a RDN consisting of cn=.... filled with surname and
+given name of the edited account. This option disables the use of
+.I accountPrimaryAttribute
+and
+.I personalTitleInDn
+in your config. The latter attributes are maintained for compatibility.
+
+
.B personalTitleInDN
.I bool
.PP
index ddd00c55ad105ea00426d63af68816b305e349f9..f03490a03b4f6423af8acf73ddf8e291e84e1b96 100644 (file)
}
}
+
+ /* Create unique DN */
+ function create_unique_dn2($data, $base)
+ {
+ $ldap= $this->config->get_ldap_link();
+ $base= preg_replace("/^,*/", "", $base);
+
+ /* Try to use plain entry first */
+ $dn= "$data,$base";
+ $attribute= preg_replace('/=.*$/', '', $data);
+ $ldap->cat ($dn, array('dn'));
+ if (!$ldap->fetch()){
+ return ($dn);
+ }
+
+ /* Look for additional attributes */
+ foreach ($this->attributes as $attr){
+ if ($attr == $attribute || $this->$attr == ""){
+ continue;
+ }
+
+ $dn= "$data+$attr=".$this->$attr.",$base";
+ $ldap->cat ($dn, array('dn'));
+ if (!$ldap->fetch()){
+ return ($dn);
+ }
+ }
+
+ /* None found */
+ return ("none");
+ }
+
+
/* Create unique DN */
function create_unique_dn($attribute, $base)
{
return ("none");
}
+
function rebind($ldap, $referral)
{
$credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc
index 30c50e47516dade4e0a802b400119bae7851dbf1..45678fac13849905349124e43ca0a50d2a9e0a7f 100644 (file)
return (0);
}
+
+ function create_initial_rdn($pattern)
+ {
+ // Only generate single RDNs
+ if (preg_match('/\+/', $pattern)){
+ msg_dialog::display(_("Error"), _("Cannot build RDN: no + allowed to build sub RDN!"), ERROR_DIALOG);
+ return "";
+ }
+
+ // Extract attribute
+ $attribute= preg_replace('/=.*$/', '', $pattern);
+ if (!in_array_ics($attribute, $this->attributes)) {
+ msg_dialog::display(_("Error"), _("Cannot build RDN: attribute is not defined!"), ERROR_DIALOG);
+ return "";
+ }
+
+ // Sort attributes for length
+ $attrl= array();
+ foreach ($this->attributes as $attr) {
+ $attrl[$attr]= strlen($attr);
+ }
+ arsort($attrl);
+
+ // Walk thru sorted attributes and replace them in pattern
+ foreach ($attrl as $attr => $dummy) {
+ if (!is_array($this->$attr)){
+ $pattern= preg_replace("/%$attr/", $this->$attr, $pattern);
+ } else {
+ msg_dialog::display(_("Error"), _("Cannot build RDN: invalid attribute parameters!"), ERROR_DIALOG);
+ break;
+ }
+ }
+
+ // Internally assign value
+ $this->$attribute= preg_replace('/^[^=]+=/', '', $pattern);
+
+ return $pattern;
+ }
+
function update_new_dn()
{
- $pt= "";
- if($this->config->get_cfg_value("personalTitleInDN") == "true"){
- if(!empty($this->personalTitle)){
- $pt = $this->personalTitle." ";
+ // Alternative way to handle DN
+ $pattern= $this->config->get_cfg_value("accountRDN");
+ if ($pattern != "") {
+ $rdn= $this->create_initial_rdn($pattern);
+ $attribute= preg_replace('/=.*$/', '', $rdn);
+ $value= preg_replace('/^[^=]+=$/', '', $rdn);
+
+ /* Don't touch dn, if $attribute hasn't changed */
+ if (isset($this->saved_attributes[$attribute]) && $this->saved_attributes[$attribute] == $this->$attribute &&
+ $this->orig_base == $this->base ){
+ $this->new_dn= $this->dn;
+ } else {
+ $this->new_dn= $this->create_unique_dn2($rdn, get_people_ou().$this->base);
}
- }
- $this->cn= $pt.$this->givenName." ".$this->sn;
- /* Permissions for that base? */
- if ($this->config->get_cfg_value("accountPrimaryAttribute") == "uid"){
- $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
+ // Original way to handle DN
} else {
- /* Don't touch dn, if cn hasn't changed */
- if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
- $this->orig_base == $this->base ){
- $this->new_dn= $this->dn;
+
+ $pt= "";
+ if($this->config->get_cfg_value("personalTitleInDN") == "true"){
+ if(!empty($this->personalTitle)){
+ $pt = $this->personalTitle." ";
+ }
+ }
+
+ $this->cn= $pt.$this->givenName." ".$this->sn;
+
+ /* Permissions for that base? */
+ if ($this->config->get_cfg_value("accountPrimaryAttribute") == "uid"){
+ $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
} else {
- $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
+ /* Don't touch dn, if cn hasn't changed */
+ if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
+ $this->orig_base == $this->base ){
+ $this->new_dn= $this->dn;
+ } else {
+ $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
+ }
}
}
}