Intranet - AD

I developed an Intranet site for my company for a year now. I have a login page which users credential store in SQL. Now I want to switch it to AD. I am using .net 3.5 and aspx. How should I go about doing something like this? I use session on username. How would this work when I use AD to authentication?
Who is Participating?
This link describes the process of authenticating via LDAP using asp.
Ricardo MartínezInformation SecurityCommented:
You need to change the authentication on the login page to check the credentials on the AD. Check this:
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

VBdotnet2005Author Commented:
I don't understand what _path is?

public LdapAuthentication(string path)
      _path = path;
VBdotnet2005Author Commented:

I got the link to work.

I can get username below. I can type it in a login page, and it works perfectly. What if I don't want to type password ? Can I use Windowsidentiy to pass it in too?

dim id as windowsidentity = windowsidentity.getcurrent
dim username as string =    <<< username

Public Function AuthenticateUser(ByVal username As String, ByVal password As String) As Boolean
        Dim root As New DirectoryEntry("LDAP://RootDSE")
        Using root
            Dim dnc As String = root.Properties("defaultNamingContext")(0).ToString()
            Dim server As String = root.Properties("dnsHostName")(0).ToString()

            Dim adsPath As String = [String].Format("LDAP://{0}/{1}", server, dnc)
            Dim authentic As Boolean = False
            Dim entry As New DirectoryEntry(adsPath, username, password)
                Dim nativeObject As Object = entry.NativeObject
                authentic = True
            Catch dsce As DirectoryServicesCOMException
                Return False
            End Try
        End Using
        Return True
    End Function
WindowsIdentity.GetCurrentUser will give you the account under which is running.

So if you are not using WindowsAuthenticaiton+Impersonation, it is not going to return the actual user most likely NT Authority\Network Service. And if you have Windows Authentication On then I don't see a use of doing LDAP authentication.

Check this for more info:

Not sure if you are looking for something like this:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.