egworld Posted December 22, 2008 Report Posted December 22, 2008 (edited) Hay i want to make a secure login for my programs like The "Team Binary Login Form". I know how to do the codeing and every thing but I want to know how to do the part on my server side, also i will upload the source file! here is the download Here is the code for people that don't download!Also i am a noob! HEHEHE! Imports System.Net Imports System.IOb Imports System.Text Public Class LoginForm1 Dim LoginStatus Dim Group Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Login() End Sub Public Sub Login() Try If UsernameTextBox.Text = "" Then MsgBox("Please enter a Username!", MsgBoxStyle.Exclamation, "Username:") Exit Sub End If If PasswordTextBox.Text = "" Then MsgBox("Please enter a Password!", MsgBoxStyle.Exclamation, "Password:") Exit Sub End If CheckLogin() If LoginStatus = "0" Then MsgBox("Invalid Username/Password" + Environment.NewLine + "Possible Server Timeout, Try Again Later", MsgBoxStyle.Information, "Login Failed!") UsernameTextBox.Text = "" PasswordTextBox.Text = "" Exit Sub ElseIf LoginStatus = "1" Then If Group = 8 Then ' Banned User Group Number MsgBox("If you was banned from the site what makes you think you can use programs made for the site", MsgBoxStyle.Critical, "Banned User") Application.Exit() Else ' Everyone Else Can Use The Program Form1.Show() Me.Close() End If Else MsgBox("There was an error while connecting. Please try again in a few minutes.", MsgBoxStyle.Critical, "Server Error") End If Catch ex As Exception End Try End Sub Public Sub CheckLogin() Try 'call our function to loginto the site and then return all its s*** as a stream Dim rssStream As System.IO.StreamReader = LoginSite(UsernameTextBox.Text, PasswordTextBox.Text) Dim rssDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument() 'load the stream as a XML file rssDoc.Load(rssStream) 'tell it what Main node to look under Dim rssItems As System.Xml.XmlNodeList = rssDoc.SelectNodes("User") Dim currentRssItem As System.Xml.XmlNode 'tells it to loop through and find all our data we want For Each currentRssItem In rssItems Dim rssDetail As System.Xml.XmlNode 'get if we are logged in or not a 0 is a Not logged in and a 1 is a logged in rssDetail = currentRssItem.SelectSingleNode("LoggedIn") If Not IsNothing(rssDetail) Then LoginStatus = rssDetail.InnerText Else LoginStatus = "0" End If 'Get the group ID rssDetail = currentRssItem.SelectSingleNode("Group") If Not IsNothing(rssDetail) Then Group = rssDetail.InnerText Else Group = "" End If 'Now that we have all our stuff lets put it into Labels so we can use it later Next Catch Err As Exception LoginStatus = "0" End Try End Sub Public Function LoginSite(ByVal username As String, ByVal pass As String) As Object Try Dim requestUriString As String = "http://www.teambinary.org/apps/authenticate/login.php" Dim request As HttpWebRequest = DirectCast(WebRequest.Create(requestUriString), HttpWebRequest) request.Method = "POST" request.ContentType = "application/x-www-form-urlencoded" Dim computerName As String = SystemInformation.ComputerName Dim textArray3 As String() = New String() {"username=" & username & "&" & "password=" & pass} Dim text2 As String = String.Concat(textArray3) Dim encoding1 As New System.Text.ASCIIEncoding Dim buffer1 As Byte() = encoding1.GetBytes(text2) Dim stream1 As IO.Stream = request.GetRequestStream stream1.Write(buffer1, 0, buffer1.Length) stream1.Close() Dim response1 As Net.HttpWebResponse = CType(request.GetResponse, Net.HttpWebResponse) Dim reader1 As New IO.StreamReader(response1.GetResponseStream) Return reader1 Catch exception1 As WebException End Try End Function Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click Me.Close() End Sub Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class Edited December 23, 2008 by egworld
sillybob123 Posted December 22, 2008 Report Posted December 22, 2008 What do you mean you need to be more clear i assume you want to make it work with your own site? for that you will need to change the linking to the SQL database of your site its pretty easy to see in the code.
egworld Posted December 23, 2008 Author Report Posted December 23, 2008 (edited) What do you mean you need to be more clear i assume you want to make it work with your own site? for that you will need to change the linking to the SQL database of your site its pretty easy to see in the code. Ok well after asking the maker of it 9 times he told me just run mysql querys and echo the result in the php. So um what your saying is to change the SQL database? Well were will it be ... (what would it look like then i can find it). I am a newb at coding, but i would like to have this on my programs just because... i will think or a reason later. I posted the code for the program in my first post Edited December 23, 2008 by egworld
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now