Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

searchUser() function hard-codes ericsson domain component #94

Open
bbbco opened this issue Sep 19, 2017 · 6 comments
Open

searchUser() function hard-codes ericsson domain component #94

bbbco opened this issue Sep 19, 2017 · 6 comments

Comments

@bbbco
Copy link

bbbco commented Sep 19, 2017

I was grepping for instances of ericsson for PR #92 and noticed something wonky.

Take a look at this function in chrome/content/adutils.js

function searchUser(searchString, wantedAttribs){
    var maxEntriesWanted = 300;
    //ensure the mandatory attribs are in the list of wantedAttribs... this is important!!
    for (let ctr = 0; ctr < mandatoryAttribs.length; ctr++){
        if (wantedAttribs.indexOf(mandatoryAttribs[ctr]) === -1){
            //do nothing and return
            return;
        }
    }
    getLDAPOperation();
    if(gLdapOperation)
    {
    	gLdapOperation.searchExt("DC=ericsson,DC=se", gLdapServerURL.scope, searchString, wantedAttribs, 0, maxEntriesWanted);
    }
}

Notice the line gLdapOperation.searchExt("DC=ericsson,DC=se", gLdapServerURL.scope, searchString, wantedAttribs, 0, maxEntriesWanted);; this does not look right, it should not be hard-coding the ericsson domain component like this, right?

@advancingu
Copy link
Member

Link to code in question.

@logological
Copy link

I agree this doesn't seem right. I don't know enough about how this code or how LDAP works to know how to fix it, though.

@mpumford
Copy link

Well I can answer the LDAP part:
Give a domain of domain.example.com you would want to split that to be:

DC=domain,DC=example,DC=com

scope would then be something like people or users so is probably okay as is.

So if this function is used it probably needs to take the configured domain as a parameter.

@advancingu
Copy link
Member

@mpumford What do you mean by "configured domain"? It would be great to see an example.

@Trim
Copy link
Member

Trim commented Oct 11, 2017

I didn't read details of the code, but seeing the name of the function searchExt, it seems that it will perform a search operation on a LDAP server.

When you do a search, you will need to define a scope of where you want to look inside the LDAP server. You can view and LDAP directory as a mathematical tree.

The text DC=ericsson,DC=se describes a branch of the tree from where you want to search users (we read this from right to left: the root of the tree is DC=se and you go through the branch DC=ericsson and from there you look for users in sub-branches and leaves).

Usually, administrators configure the root of the tree as a domain name which will be only used inside the directory (here, in the code, the related domain is ericsson.se).

Edit:
According to the Mozilla XUL interface definition, we are well talking about the base root to run the search (usually named "base dn"): http://doxygen.db48x.net/mozilla/html/interfacensILDAPOperation.html#01e3948b997e7beb2aded06510af6260

@Trim
Copy link
Member

Trim commented Feb 9, 2018

Well, this method doesn't seem to be really used:

adrien@bureau:~/code/exchangecalendar$ grep --exclude-dir .git -rn searchUser
common/content/adutils.js:120:        searchUserByEmail(mailID);
common/content/adutils.js:124:        //this is why the mandatoryAttrib check is important in searchUser
common/content/adutils.js:243:function searchUser(searchString, wantedAttribs) {
common/content/adutils.js:260:function searchUserByEmail(mailID) {
common/content/adutils.js:272:    searchUser(searchString, wantedAttribs);
common/content/adutils.js:277:function searchUserBySignum(signum) {
common/content/adutils.js:288:    searchUser(searchString, wantedAttribs);
common/content/adutils.js:301:        searchUserBySignum(mgrSignum);
common/content/adutils.js:315:            searchUserBySignum(empSignum);
common/content/adutils.js:503:    searchUserByEmail(searchemail);

I suspect that was an helper for some specific Ericsson configuration.

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

No branches or pull requests

5 participants