473,396 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Membership.FindUsersByName

Can anyone tell me why FindUsersByName() returns a collection? Isn't it
necessary that user names are unique (how else would passwords be
validated?)

And what is the best way to determine if a user name is already in use?
Preferrably, I could do this without raising an exception--I just want to
know whether or not they exist.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Dec 17 '07 #1
4 3409
the function does a sql like and supports sql wildcards, so even though
names are unique, the find can return multiples.

this also means to avoid injection attacks, you should check for sql
wildcard characters in usernames and email addresses.
-- bruce (sqlwork.com)
"Jonathan Wood" wrote:
Can anyone tell me why FindUsersByName() returns a collection? Isn't it
necessary that user names are unique (how else would passwords be
validated?)

And what is the best way to determine if a user name is already in use?
Preferrably, I could do this without raising an exception--I just want to
know whether or not they exist.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Dec 18 '07 #2
You're looking at the wrong function. The FindUsersByName is not meant to
get a user. It's meant to find a number of users that are similar to the
username entered. The stored procedure behind this uses LIKE instead of =,
this means you could say bob% and get all usernames that begin with bob.

What you want, instead is the GetUser. Best way to see if a user exists is
to just try a call to GetUser and if it returns null, then there is no user.
If it returns a MembershipUser object that isn't null, then you have a user.
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:ek**************@TK2MSFTNGP04.phx.gbl...
Can anyone tell me why FindUsersByName() returns a collection? Isn't it
necessary that user names are unique (how else would passwords be
validated?)

And what is the best way to determine if a user name is already in use?
Preferrably, I could do this without raising an exception--I just want to
know whether or not they exist.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Dec 18 '07 #3
Ah! Many thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:CB**********************************@microsof t.com...
the function does a sql like and supports sql wildcards, so even though
names are unique, the find can return multiples.

this also means to avoid injection attacks, you should check for sql
wildcard characters in usernames and email addresses.
-- bruce (sqlwork.com)
"Jonathan Wood" wrote:
>Can anyone tell me why FindUsersByName() returns a collection? Isn't it
necessary that user names are unique (how else would passwords be
validated?)

And what is the best way to determine if a user name is already in use?
Preferrably, I could do this without raising an exception--I just want to
know whether or not they exist.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Dec 18 '07 #4
Mark,
You're looking at the wrong function. The FindUsersByName is not meant to
get a user. It's meant to find a number of users that are similar to the
username entered. The stored procedure behind this uses LIKE instead of =,
this means you could say bob% and get all usernames that begin with bob.
I'm not trying to get a user, I'm trying to find the number of users with a
specific user name or, in my case, email.
What you want, instead is the GetUser. Best way to see if a user exists is
to just try a call to GetUser and if it returns null, then there is no
user. If it returns a MembershipUser object that isn't null, then you have
a user.
Here's where I get lost. Scanning the docs, I couldn't see anything about
GetUser returning null. If it does, that's perfect. But instead the
mentality seems to be raise an exception any time things aren't the way a
particular method thinks they should be.

Is there a way I'd be able to tell GetUser can return null on my own? That
would be a great help.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:ek**************@TK2MSFTNGP04.phx.gbl...
>Can anyone tell me why FindUsersByName() returns a collection? Isn't it
necessary that user names are unique (how else would passwords be
validated?)

And what is the best way to determine if a user name is already in use?
Preferrably, I could do this without raising an exception--I just want to
know whether or not they exist.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Dec 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul Keegstra | last post by:
Hi, I am currently working on an asp.net 2.0 web site that is a replacement of a classic asp web site. The current web site uses a Commerce Server 2002 database for storing user information. ...
2
by: Balaji | last post by:
Hi All, Can I use more than one membership provider for a given website? I understand only one of them could be default one. If yes, then how to programmatically access the other membership...
3
by: ryan.mclean | last post by:
Hello everyone, I am wondering, can the membership provider be changed at runtime? Perhaps the connectionStringName? I would like to use a different database based on the server the site is...
4
by: =?Utf-8?B?Q2hyaXMgQ2Fw?= | last post by:
I have been having some trouble with implementing a custom Membership Provider. We have a custom data store and business logic that pulls user information. I need some level of functionality...
0
by: Fendi Baba | last post by:
I need to implement a login system using Asp.net 2.0 login module( membership provider) with password being case insensitive. I wrote a class Accessmembershipprovider.vb and below is my code....
3
by: Glenn | last post by:
My current classic-ASP site has users, projects, roles and the 2.0 membership looks like a perfect fit, but I'm having trouble finding examples of how to have users that belong to different...
1
by: =?Utf-8?B?ZVByaW50?= | last post by:
Asp.Net v2.0 I have created a web application and I am using it from a single website and database. The web application has different ‘portals’ – each independent and I am using the...
1
by: =?Utf-8?B?ZVByaW50?= | last post by:
Asp.Net v2.0 I have created a web application and I am using it from a single website and database. The web application has different ‘portals’ – each independent and I am using the...
8
by: Nick | last post by:
Hi there, Membership.GetNumberOfUsersOnline() works great the first time, then jumps up to the number of users registered in the system. I have tried enumerating through each user individually...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.