Closed Bug 107558 Opened 23 years ago Closed 23 years ago

Unable to add LDAP directory

Categories

(MailNews Core :: LDAP Integration, defect, P1)

x86
Windows 2000

Tracking

(Not tracked)

VERIFIED WORKSFORME
mozilla0.9.8

People

(Reporter: erich, Assigned: srilatha)

References

Details

(Keywords: regression)

Attachments

(2 files, 4 obsolete files)

Steps:
Edit/Preferences
Mail & Newsgroups/Addressing
click "Edit Directories.."
click Add
type in the information for an LDAP server and click OK
(your new server shows up in the list)
click OK
(the new server doesn't make it back to the main Addressing window)
click Edit Directories again
(the new server is gone)

Also, I just imported this profile from NS4.77, and it did not bring over the
LDAP information from that, while it has in the past.

build 2001103003, win32-installer, windows 2000
Taking this. This is a regression caused by the checkin for bug # 106159
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Keywords: regression
Attached patch patch v1 (obsolete) — Splinter Review
Attached patch patch v2 (obsolete) — Splinter Review
Attachment #56002 - Attachment is obsolete: true
In the new patch, I have createChildList as a method in the interface 
nsILdapPrefsService. and in pref-directory.js I'm calling createChildList on 
nsILdapPrefsService. 
in nsLDAPPrefsService.prototype.createChildList

(last 4 lines)
  aCount.value = count;
  if (!count)
    return null;
  return childList;

You assign aCount.value to count ... but then if no count return null - 
Put the return before you do the assignment to aCount.value
   (this will avoid js errors)

You probably don't want to call a local variable gPrefInt either :)
Attached patch patch v3 (obsolete) — Splinter Review
Attachment #56161 - Attachment is obsolete: true
r=chipc@netscape.com  looks good to me
I think I see some issues with this patch; hope you don't mind me
chiming in with some review comments.  In particular...

a) since |createChildList| is only ever called with "ldap_2.servers" as
the |prefRoot|, is there any reason not to define this as a local |const|
var in the .js file rather than making it a param?  If you do this,
|parent| looks like it could be const as well.

b) when implementing XPCOM interfaces in JS, the way to indicate
errors to the caller is to throw an nsresult rather than returning
null.

   throw Components.results.NS_ERROR_FAILURE;

c) the regexp |re| currently in use doesn't look quite right: [.] will
match any character, not just a dot.  But regexps are more heavyweight
than necessary for this job anyway; instead of

   string = directoriesList[i].substr(parent.length, 
                                      directoriesList[i].length);
   strLen = string.search(re);

you might want to consider using

   strLen = directoriesList[i].indexOf(".", parent.length);

d) can you add @arg, @return, and @exception doxygen comments
documenting the possible arguments, the return code, and the possible
exceptions that can be thrown by the implementor?
Comment on attachment 56243 [details] [diff] [review]
patch v3

documentation, documentation documentation!
What is createChildList doing? we need better variable names than 
"string" - what does "string" represent? I guess I'm just confused 
because I can't tell exactly what the point of createChildList is.. how does
it differ from getChildList()? 

Also, why create a seperate array and return that? Why not just muck 
with the original "directoriesList" and
remove the entries that don't match your regular expression?

Also, the varable "regexp" is just "", but it sure doesn't look like a 
regular expression to me.. it looks like some kind of match string.

Maybe all these questions would be cleared up if I had an explanation of what
 this function is doing.
Setting milestone to mozilla 0.9.6.
Severity: normal → major
Priority: -- → P1
Target Milestone: --- → mozilla0.9.6
Attached patch patch v4 (obsolete) — Splinter Review
Comment on attachment 56634 [details] [diff] [review]
patch v4

does this patch even work?
This line:
+      strLen = directoriesList[i].indexOf(".", parent.length);

will always return a value of 5, because parent (which is ALWAYS "ldap_2.servers.")
has a "." in the 5th position in the string... which means that the following if() statement will ALWAYS be true, and you'll always be truncating directoriesList[i] down to the "servers." portion of the string..

What I think dmose was saying with the whole const isssue, is that
if createChildList will always pass in "ldap_2.servers",
why not just change the api to:
void getServerList(out unsigned long aCount, [array, size_is(aCount), retval] out string aChildArray);
and then internally always use "ldap_2.servers."
Attachment #56634 - Flags: needs-work+
alecf: actually, it won't always return 5; the second parameter to indexOf means
"start searching at this index", so this should actually work ok.  you are right
as to my original intent on the const stuff, but it looks like srilatha's new
patch may do better than that (I don't know the code well enough to be sure)
since it takes an existing nsIPrefBranch rather than creating a whole new one.
In the new patch, in createChildList I just assume ldap_2.servers. Actually in 
patch v3 you could pass any root and get the child List.
dmose is right, about indexOf. 
Alec: the answer to your question, how does createChildList differ from 
getChildList.

The array that is created by getChildList looks like this:
ldap_2.servers.Netscape.description
ldap_2.servers.Netscape.filename
ldap_2.servers.Netscape.replication
ldap_2.servers.Netscape.uri
ldap_2.servers.test.description
ldap_2.servers.test.filename
ldap_2.servers.test.replication
ldap_2.servers.test.uri

The arrray that is created by createChildList looks like this:
ldap_2.servers.Netscape
ldap_2.servers.test
Attached patch patch v5Splinter Review
chip, alec please review the last patch.
Attachment #56243 - Attachment is obsolete: true
Attachment #56634 - Attachment is obsolete: true
In the last patch I changed the api name to getServerList. Also I am using 
only one array directoriesList.
After talking to Alec over aim, we decided to go with the two array solution 
since it is much cleaner.
Comment on attachment 56775 [details] [diff] [review]
the two array solution

sr=alecf, with a few extra lines of comments that srilatha and I discussed

Also, I would like r=dmose on this
Attachment #56775 - Flags: superreview+
Comment on attachment 56775 [details] [diff] [review]
the two array solution

OK, two minor nits:

In the doxygen comments:

@aChildArray        Receives the array with "ldap_2.servers.<server-name>".

Shouldn't that really be

@param	aChildArray	stuff...

Also

+  try {
+    directoriesList = prefBranch.getChildList(prefRoot, prefCount);
+  }
+  catch (ex) {
+    directoriesList = null;
+  }

Instead of setting directoriesList to null here and executing a bunch more code, either throw a new NS_ERROR_FAILURE, or else remove the try/catch wrapper completely and allow the exception from nsIPref to propagate up the stack.

Fix those, and you've got r=dmose.
Attachment #56775 - Flags: review+
Fix checked in
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
I'm seeing this again 20001112603, Windows XP Pro
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
WFM Mac OSX 2001112705 build.
Moving to 0.9.8.  This worksforme on the 11/26 build on Win 2000.  yulian, are
you able to reproduce this?
Target Milestone: mozilla0.9.6 → mozilla0.9.8
sorry, changed my mind.  If we can reproduce we should fix it soon.
Target Milestone: mozilla0.9.8 → mozilla0.9.7
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Works for me with 2002010703 Wins build on NT.
Worksforme on windows XPPro with 2002010703. Please reopen this bug if you are 
still seeing the problem
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → WORKSFORME
Verified with Jan-7-2002 Wins build.
Status: RESOLVED → VERIFIED
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: