ditaoctavia / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

Issue creating new user for 389 #569

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to use PWM as a front end for our 389 DS LDAP server. Because the 
username is typically bound to uid rather than the default cn, I've changed the 
appropriate values. However, 389 requires cn to also be set.

Is there a way I can automatically generate it by putting the first and last 
name together without having to ask them again on the new user module? I've 
tried macros and a hidden field with %givenName% %sn% as a placeholder, both 
without success.

What version of PWM are you using?
1.7.1

What ldap directory and version are you using?
389 DS, 1.2.11.15

Please paste any error log messages below:
When I didn't have it at all -
2014-05-27 21:11:58, ERROR, servlet.NewUserServlet, {21} 5049 
ERROR_NEW_USER_FAILURE (unexpected ldap error creating user entry: [LDAP: error 
code 65 - missing attribute "cn" required by object class "inetOrgPerson"

When I tried a macro -
2014-05-27 21:18:12, ERROR, servlet.NewUserServlet, {23} 5049 
ERROR_NEW_USER_FAILURE (unexpected ldap error creating user entry: [LDAP: error 
code 21 - cn: value #0 invalid per syntax

Original issue reported on code.google.com by lin...@gmail.com on 28 May 2014 at 5:36

GoogleCodeExporter commented 9 years ago
Hi, 

I solve this problem by changing the newuser.js and the form.jsp files as 
follow :
newuser.js: Add the functions
function autoGen(prenom, nom){
    var prenom = document.getElementById("givenName").value;
    var nom = document.getElementById("sn").value;
    uidGen(prenom, nom);
    cnGen(prenom, nom);
}

function uidGen(prenom, nom){

    prenom = prenom.replace('-', ' ').replace('\'', ' ');
    var prenoms = prenom.split(' ');

    var uidPrenom = "";
    for (var i=0;i<prenoms.length;i=i+1){
        uidPrenom = uidPrenom + prenoms[i].substring(0, 1);
    }

    var noms = nom.split(' ');

    var uidNom = "";
    for (var i=0;i<noms.length;i=i+1){
        uidNom = uidNom + noms[i];
    }

    var uid = uidPrenom.toLowerCase() + uidNom.toLowerCase();
    document.getElementById("uid").value = uid;
}

function cnGen(prenom, nom){
    var cn = prenom + ' ' + nom;
    document.getElementById("cn").value = cn;
}

forms.jsp : change the input tag pour appeler la function autoGen :
<input style="text-align: left;" id="<%=loopConfiguration.getName()%>" 
type="<%=loopConfiguration.getType()%>" class="inputfield"
       name="<%=loopConfiguration.getName()%>" value="<%= currentValue %>"
        <%if(loopConfiguration.getPlaceholder()!=null){%> placeholder="<%=loopConfiguration.getPlaceholder()%>"<%}%>
        <%if(loopConfiguration.isRequired()){%> required="required"<%}%>
        <%if(loopConfiguration.isConfirmationRequired()) { %> onkeypress="getObject('<%=loopConfiguration.getName()%>_confirm').value=''"<% } %>
       maxlength="<%=loopConfiguration.getMaximumLength()%>" 
                <%if((loopConfiguration.getName().equals("sn"))||(loopConfiguration.getName().equals("givenName"))){%> onblur='autoGen(this.form.givenName.value, this.form.sn.value)'<%}%>/>

Original comment by mdii.al...@gmail.com on 8 Jul 2014 at 2:23