hi there,

i have a desktop application that in visual studio 2008 standard edition in C#.currently i have a userlogin in the mdf file and when login in to the system. what i want is to make the windows credinals in to use. how can i upgrade my application so that when the users clicks the login button in the desktop application if the windows username and the password are correct, how to i let the user to login to the desktop application. how can i make this.


thanxxxxxxxx

If the user successfully logged in then just add the program to startup.

System.Environment.UserName

If the user successfully logged in then just add the program to startup.

System.Environment.UserName

is this the only code that i have to add.

how is this done.when the windows user login is successful how can i check the usernsma and password and check and let the desktop application to login. please can u explain the procedure or the steps in this situation??


thanxxxxxxxxxx

If you intend to use your own DB of username and password then you must create you own login form and test the entered values against those stored in your DB.

If you intend to use the Windows login credentions to validate access to your application then this is much more complicated to do.
You will need to investigate the objects in the System.Security.Principal namespace. Particularly the IIdentity and IPricipal interfaces.
And also know how to properly use the LogonUser fuction in advapi32.dll (below).

[DllImport("advapi32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
            int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.