Erm, do I need Visual Studio in my Windows Server 2008 to make my website work? Somehow,I've set my Content Directory and my Visual Directory to the same folder with all my ASP.NET pages + codes inside but it doesn't work at all. Tried switching authentication mode to forms authentication. Enable directory browsing and all that but it doesn't work too. How am I suppose to go about doing it?
This is my web.config codes
<?xml version="1.0"?>
.web>
.codedom>
.webServer>
My login code behind codes
Imports System.DirectoryServices
Partial Public Class Login
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal Username As String, ByVal Password As String) As Boolean
Dim Success As Boolean = False
Dim Entry As New System.DirectoryServices.DirectoryEntry("LDAP://WIN-O0WXTK9XZU0.App2.ict.np.edu.sg/DC=App2,DC=ict,DC=np,DC=edu,DC=sg" & Domain, Username, Password)
Dim Searcher As New System.DirectoryServices.DirectorySearcher(Entry)
Searcher.SearchScope = DirectoryServices.SearchScope.OneLevel
'Try
' Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
' Success = Not (Results Is Nothing)
'Catch
' Success = False
'End Try
Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
Success = Not (Results Is Nothing)
Return Success
End Function
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click
Dim isauthenticated As Boolean = AuthenticateUser()
If isAuthenticated Then
Response.Redirect("Default.aspx?")
Else
'code here to display incorrect login details
lblError.Text = "Please enter correct username and password"
End If
End Sub
Private Function AuthenticateUser() As Boolean
Dim username As String = txtUsername.Text
Dim password As String = txtPassword.Text
'Dim domain As String = this can be in a config file, hard coded (I wouldnt do that), or inputed from the UI
Dim domain As String = "App2.ict.np.edu.sg"
Dim isAuthenticated As Boolean = ValidateActiveDirectoryLogin(domain, username, password)
Return isAuthenticated
End Function
End Class