473,804 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check name in xml file B4 MembershipProvi der.CreateUser

Hi,
I need to check that someone signing up is listed in an xml file. I am
using a customer membership provider for Access and trying to integrate
the xml check into that. Am I on the right track? The code below runs
but it results in "Your account was not created. Please try again."
It's obviously not picking up username and comparing it.

code.vb

' MembershipProvi der.CreateUser
'

Public Overrides Function CreateUser(user name As String, _
password As String, _
email As String, _
passwordQuestio n As String, _
passwordAnswer As String, _
isApproved As Boolean, _
providerUserKey As Object, _
ByRef status As MembershipCreat eStatus) As MembershipUser

Dim Args As ValidatePasswor dEventArgs = _
New ValidatePasswor dEventArgs(user name, password, True)

OnValidatingPas sword(args)

If args.Cancel Then
status = MembershipCreat eStatus.Invalid Password
Return Nothing
End If
If RequiresUniqueE mail AndAlso GetUserNameByEm ail(email) <> ""
Then
status = MembershipCreat eStatus.Duplica teEmail
Return Nothing
End If

Dim u As MembershipUser = GetUser(usernam e, False)

If u Is Nothing Then
Dim createDate As DateTime = DateTime.Now

If providerUserKey Is Nothing Then
providerUserKey = Guid.NewGuid()
Else
If Not TypeOf providerUserKey Is Guid Then
status = MembershipCreat eStatus.Invalid ProviderUserKey
Return Nothing
End If
End If
'........start xml

Dim strUser As String = username
Dim blnIsAuthentica ted As Boolean
Dim objXMLDoc As New XMLDocument()
Try
objXMLDoc.Load( "\Administratio n\dbs\clientids .xml")
Catch objError As Exception
status = MembershipCreat eStatus.Provide rError
End Try

Dim UserNodes As XmlNodeList
UserNodes = objXMLDoc.GetEl ementsByTagName (username)

'see if we found an element with this username
If Not UserNodes Is Nothing Then
Dim blnUserExists As Boolean = True
Dim strUserCheck As String = username
Try
strUserCheck = UserNodes(0).Fi rstChild().Valu e
Catch objError As Exception
status = MembershipCreat eStatus.Provide rError
blnUserExists = False
End Try

If blnUserExists = True Then
blnIsAuthentica ted = True
Else
status = MembershipCreat eStatus.Provide rError

End if
End If

If blnIsAuthentica ted Then

'...... into database code .....
Dim conn As OdbcConnection = New
OdbcConnection( connectionStrin g)
Dim cmd As OdbcCommand = New OdbcCommand("IN SERT INTO [" &
tableName & "]" & _
" (PKID, Username, Password, Email, PasswordQuestio n, " &
_

etc ...... code cut

Try

conn.Open()

Dim recAdded As Integer = cmd.ExecuteNonQ uery()

If recAdded > 0 Then
status = MembershipCreat eStatus.Success
Else
status = MembershipCreat eStatus.UserRej ected
End If
Catch e As OdbcException
If WriteExceptions ToEventLog Then
WriteToEventLog (e, "CreateUser ")
End If

status = MembershipCreat eStatus.Provide rError
Finally
conn.Close()
End Try
'.....
End if
'......

Return GetUser(usernam e, False)
Else
status = MembershipCreat eStatus.Duplica teUserName
End If

Return Nothing
End Function

clientids.xml
<?xml version="1.0"?>
<username>
<foster></foster>
<jessie></jessie>
<shadow></shadow>
</username>

Apr 3 '06 #1
0 2135

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

Similar topics

3
1985
by: WB | last post by:
Hi, I am revamping my company's website using .Net 2.0 & C#. I would like to implement my own custom membership provider to manage membership information already stored in my existing SQL 2000 database. Therefore, I need to create a class the inherits the MembershipProvider abstract class from the System.Web.Security namespace. For instance, I need to provide a method in this class for creating user as follows:
4
1507
by: ezra epstein | last post by:
I've got a user with CREATEUSER privs. I've not granted that user and DB specific privs but it can do what it will with non-public schemas... Is there a user that can do SET SESSION AUTHORIZATION but does not have privs otherwise? Basically I want a login user that can then set session auth... to any other user but otherwise has no privs. (Having createuser is acceptable.) I'm looking into a way to give connection pooled access to a...
4
2100
by: MLH | last post by:
A97: If I create a new user with CreateUser Method, is she automatically a member of Users group? Or, do I have to append her to that group?
3
2088
by: Diego | last post by:
I've created a Custom MembershipProvider, in the user creation i have to return somehow the ProviderUserKey but inside the MembershipProvider I have no access to the session to store the info. Any suggesions appreciated. Thanks, Diego
0
2063
by: Portman | last post by:
I've used the Membership classes in an ASP.NET 2.0 application to create an application that interfaces with an older SQL Server 2000 database. Everything is working except the following... Like many websites, users can sign up by filling in a form. Because we're interacting with other databases, I eschewed the CreateUserWizard control and wrote my own logic programmatically, making use of the Membership.CreateUser() method. ...
2
2635
by: Mark Olbert | last post by:
So far, I am more than a little underwhelmed by the Membership API in ASPNET2, and the ASP.NET Configuration wizard in VS2005. The latter is slow as a pig whenever it does anything. Oh well, at least it's given me a chance to brush up on my Spider Solitaire game. In any event, I am trying to implement a custom MembershipProvider for a website. Why? Because the default one that gets created by the supplied wizard is way over the top, in...
3
2026
by: VB Programmer | last post by:
I am getting this error: error BC30456: 'CreateUser' is not a member of 'Membership'. What does that mean? Here's my code. It seems correct (no squigglies, etc...) ' store it in db Dim result As System.Web.Security.MembershipCreateStatus Try Dim newUser As MembershipUser = Membership.CreateUser(Me.txtUsername.Text, Me.txtPassword.Text,
5
3265
by: ibiza | last post by:
Hi all, I'd like to write my own MembershipProvider for my ASP.NET 2.0 web application but I fear all the code to write. Basically, I only want to add a few functionalities like being able to change a username (which the standard MembershipProvider does not allow), add some fields to a user (e.g.: "Area", a few others...) and some other functions I may not think of right now. How could I write my own MembershipProvider while still...
1
2118
by: John | last post by:
Hi I am using the membership createuser method but need to find the error when one arise. I am using the below code; Public Function CreateUser(ByVal Username As String, ByVal Password As String, ByVal Email As String, ByRef ErrMsg As String) As Boolean Try Membership.CreateUser(Username, Password, Email) CreateUser = True
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.