# Local machine account validation using C# .NET 2.0



## garv84 (Dec 3, 2008)

Hi..

 I have a login dialog with user name and password.I want two types of authentications.

1> Local machine username_passowrd authentication.(ie the one present in Control panel_administrative tools_Computer management_local users and grps_users.)

2>Active directory(AD) username_passowrd authentication.

Can neone show some light with a C# snippet..?


----------



## astroutkarsh (Dec 3, 2008)

hello 
there are many ways to do this.
you need to use windows services to get account name / User name.
If you want to user ADS, then you need to use LDAP for ADS access.
Can you provide more details i.e. what exactly you want to do?


----------



## garv84 (Dec 3, 2008)

As i said i have a simple login form which requires username and pssword as credentials to be provided correctly in order to log into a particular application.My first priority is to authenticate against local machine accounts for username and pswd...ie the u_name and pswd that we need to login to the system.

How can i use windows services to validate the username and pswd using C#..?

Thanks for replying.can you provide me a solution.


----------



## astroutkarsh (Dec 4, 2008)

I m bizy, so just giving few links here

*microsoft.apress.com/feature/79/using-active-directory-application-mode-in-web-applications

*msdn.microsoft.com/en-us/library/aa302397.aspx

*powershelllive.com/blogs/lunch/arc...domains-computers-and-binding-to-objects.aspx


I will edit n update my post for rest of the things ( Windows service) in few hours.
Till then go thru above links.


----------



## garv84 (Dec 4, 2008)

That will be great.thanks.

using System.DirectoryServices;
string username = System.Environment.UserName;

this gives me the current windows logon username and i can easily validate that wth the one entered by the user in the login_form.But what about the password validation...?

thanks for the links regarding AD authentication of the credentials.looking forward 4ur next posts.Thanks again.


----------



## astroutkarsh (Dec 4, 2008)

w/c.
sorry for late Repl.

Due to security permissions, windows does not allow to validate Password. You need to find some other-way.

*support.microsoft.com/kb/316748 this link will give you a brief idea abt security etc.

Most of the time these are the Intranet Web Applications that uses AD Uses Authe / Machine Users.
These URLs (Intranet) are placed in Trused Site zone and verified against Username only.
still if u need password validation, Search on ASP.Net forum or Expert Exchange.
Let me know if u want something more.


----------

