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.
Alexey Smirnov - 25 Oct 2007 19:04 GMT
> I have a simple login form to authenticate users. A code segment looks like
> this:
[quoted text clipped - 29 lines]
>
> Am a newbie in this area. Any insight appreciate.
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet.security
/browse_thread/thread/39d7de4f551ca156/76de752c8f2ce6fd