473,387 Members | 3,787 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,387 software developers and data experts.

check name in xml file B4 MembershipProvider.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

' MembershipProvider.CreateUser
'

Public Overrides Function CreateUser(username As String, _
password As String, _
email As String, _
passwordQuestion As String, _
passwordAnswer As String, _
isApproved As Boolean, _
providerUserKey As Object, _
ByRef status As MembershipCreateStatus) As MembershipUser

Dim Args As ValidatePasswordEventArgs = _
New ValidatePasswordEventArgs(username, password, True)

OnValidatingPassword(args)

If args.Cancel Then
status = MembershipCreateStatus.InvalidPassword
Return Nothing
End If
If RequiresUniqueEmail AndAlso GetUserNameByEmail(email) <> ""
Then
status = MembershipCreateStatus.DuplicateEmail
Return Nothing
End If

Dim u As MembershipUser = GetUser(username, 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 = MembershipCreateStatus.InvalidProviderUserKey
Return Nothing
End If
End If
'........start xml

Dim strUser As String = username
Dim blnIsAuthenticated As Boolean
Dim objXMLDoc As New XMLDocument()
Try
objXMLDoc.Load("\Administration\dbs\clientids.xml" )
Catch objError As Exception
status = MembershipCreateStatus.ProviderError
End Try

Dim UserNodes As XmlNodeList
UserNodes = objXMLDoc.GetElementsByTagName(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).FirstChild().Value
Catch objError As Exception
status = MembershipCreateStatus.ProviderError
blnUserExists = False
End Try

If blnUserExists = True Then
blnIsAuthenticated = True
Else
status = MembershipCreateStatus.ProviderError

End if
End If

If blnIsAuthenticated Then

'...... into database code .....
Dim conn As OdbcConnection = New
OdbcConnection(connectionString)
Dim cmd As OdbcCommand = New OdbcCommand("INSERT INTO [" &
tableName & "]" & _
" (PKID, Username, Password, Email, PasswordQuestion, " &
_

etc ...... code cut

Try

conn.Open()

Dim recAdded As Integer = cmd.ExecuteNonQuery()

If recAdded > 0 Then
status = MembershipCreateStatus.Success
Else
status = MembershipCreateStatus.UserRejected
End If
Catch e As OdbcException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "CreateUser")
End If

status = MembershipCreateStatus.ProviderError
Finally
conn.Close()
End Try
'.....
End if
'......

Return GetUser(username, False)
Else
status = MembershipCreateStatus.DuplicateUserName
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 2113

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

Similar topics

3
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...
4
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...
4
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
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....
0
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...
2
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...
3
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...
5
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.