"index out of range ..." error when querying AD?
- From: "E. Kwong" <ekwong999AThotmail.com>
- Date: Wed, 24 Oct 2007 15:17:28 -0700
I have a simple login form to authenticate users. A code segment looks like
this:
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("name");
search.PropertiesToLoad.Add("givenname");
search.PropertiesToLoad.Add("sn");
search.PropertiesToLoad.Add("mail");
SearchResult result = search.FindOne();
string fullname = (string)result.Properties["name"][0];
string uname = (string)result.Properties["cn"][0];
string firstname = (string)result.Properties["givenname"][0];
string lastname = (string)result.Properties["sn"][0];
string mmail = (string)result.Properties["mail"][0];
When I tested with several user accounts, some authenticated perfectly fine,
some threw the exception "Index was out of range. Must be non-negative and
less than the size of the collection. Parameter name: index" . The
exception was eventually traced to the " string mmail =
(string)result.Properties["mail"][0]; " statement. So is this because that
user has no email in AD? How best to handle this?
Am a newbie in this area. Any insight appreciate.
.
- Follow-Ups:
- Re: "index out of range ..." error when querying AD?
- From: Alexey Smirnov
- Re: "index out of range ..." error when querying AD?
- Prev by Date: "index out of range ..." error when querying AD
- Next by Date: Re: "index out of range ..." error when querying AD?
- Previous by thread: "index out of range ..." error when querying AD
- Next by thread: Re: "index out of range ..." error when querying AD?
- Index(es):