473,789 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Current Login to another machine

Dear All,

I would like to perform a simple task by program (VB.Net or VC#.Net).

When a user logins the windows and try to run my program, how can I use his login information (username and password) to authenicate against another PC, e.g. using DirectoryEntry object?

I have these lines of code, but it needs the user to enter username and password in Textboxes txtUsername and txtPassword respectively. I would like to use the current login session information to do the job instead..
System.Director yServices.Direc toryEntry usr = new DirectoryEntry( entryPC.Path, txtUsername.Tex t, txtPassword.Tex t);
string strUserID;
try
{
strUserID = usr.NativeGuid;
MessageBox.Show ("Login correct!");
}
catch
{
MessageBox.Show ("Login Incorrect!");
}

Thanks for your help.
--------------------------------
From: Stephen Yip

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>EHsuCqGmSUa 45Rjc8gxZLg==</Id>
Jul 21 '05 #1
2 1649
You can't get the password from an authenticated logon session (thank God).
I'm not clear on why you want to authenticate an authenticated user on
another PC?

Willy.

"Stephen Yip via .NET 247" <an*******@dotn et247.com> wrote in message
news:u8******** ******@TK2MSFTN GP09.phx.gbl...
Dear All,

I would like to perform a simple task by program (VB.Net or VC#.Net).

When a user logins the windows and try to run my program, how can I use
his login information (username and password) to authenicate against
another PC, e.g. using DirectoryEntry object?

I have these lines of code, but it needs the user to enter username and
password in Textboxes txtUsername and txtPassword respectively. I would
like to use the current login session information to do the job instead..
System.Director yServices.Direc toryEntry usr = new
DirectoryEntry( entryPC.Path, txtUsername.Tex t, txtPassword.Tex t);
string strUserID;
try
{
strUserID = usr.NativeGuid;
MessageBox.Show ("Login correct!");
}
catch
{
MessageBox.Show ("Login Incorrect!");
}

Thanks for your help.
--------------------------------
From: Stephen Yip

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>EHsuCqGmSUa 45Rjc8gxZLg==</Id>

Jul 21 '05 #2


Hi,

You dont need to authenicate again to access "X" pc. You
can use current session and can access "X"(if you have
permissions).

IntPtr token = new IntPtr(0);
bool isValidUser = LogonUser(txtLo ginName.Text,
txtDomain.Text, txtPassword.Tex t, (int)
LOGON32_LOGON_N ETWORK, (int)LOGON32_PR OVIDER_DEFAULT, ref
token);

if(isValidUser == false)
{

Msg.Text = "Wrong user
name or password<br>";
}
else
{
IntPtr token2 = new IntPtr
(token.ToInt32( ));
WindowsIdentity l_Wid =
new WindowsIdentity (token2);
WindowsPrincipa l wp = new
WindowsPrincipa l(l_Wid);

System.Threadin g.Thread.Curren tPrincipal = wp;

HttpContext.Cur rent.User =
wp;
//////////////////////////
// Declare the logon types as constants
const long LOGON32_LOGON_I NTERACTIVE = 2;
const long LOGON32_LOGON_N ETWORK = 3;

// Declare the logon providers as constants
const long LOGON32_PROVIDE R_DEFAULT = 0;
const long LOGON32_PROVIDE R_WINNT50 = 3;
const long LOGON32_PROVIDE R_WINNT40 = 2;
protected
System.Web.UI.W ebControls.Text Box TextBox1;
const long LOGON32_PROVIDE R_WINNT35 = 1;

[DllImport("adva pi32.dll",Entry Point
= "LogonUser" )]
private static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider ,
ref IntPtr phToken);
-----Original Message-----
Dear All,

I would like to perform a simple task by program (VB.Net or VC#.Net).
When a user logins the windows and try to run my program, how can I use his login information (username and
password) to authenicate against another PC, e.g. using
DirectoryEntry object?
I have these lines of code, but it needs the user to enter username and password in Textboxes txtUsername and
txtPassword respectively. I would like to use the current
login session information to do the job instead..System.Directo ryServices.Dire ctoryEntry usr = new DirectoryEntry( entryPC.Path, txtUsername.Tex t,
txtPassword.Tex t);string strUserID;
try
{
strUserID = usr.NativeGuid;
MessageBox.Show ("Login correct!");
}
catch
{
MessageBox.Show ("Login Incorrect!");
}

Thanks for your help.
--------------------------------
From: Stephen Yip

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>EHsuCqGmSU a45Rjc8gxZLg==</Id>
.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4876
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are reports that the users need, which could be in html, php, asp, jsp, whatever. Now I am trying to eliminate the login window entirely. In an html request, the client (firefox, ie, etc) sends the clients hostname, IP, a bunch of other stuff, but...
11
2973
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following section: <authorization> <deny users="?" /> <allow users="*" /> </authorization> In the root folder where the other forms are located I have a Web.config
4
2424
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). The problem is that the user who "owns" the service is always the ASPNET account. That's not good since you don't see the actual application (because it's owned by ASPNET). I've tried changed the processmodel section in the machine.config file to...
0
2210
by: Mach Runner | last post by:
I am implementing a secure website using the ASP.NET FormsAuthentication model. I have taken the simplest code examples from MSDN (login.aspx,default.aspx, web.config) but cannot get proper behavior on my machine. As an unauthenticated user, I navigate to the website http://localhost/XXX. global.Authenticate_Request considers sending default.apsx but cannot find any authentication cookie in the Context object, so the request is...
2
322
by: Stephen Yip via .NET 247 | last post by:
Dear All, I would like to perform a simple task by program (VB.Net or VC#.Net). When a user logins the windows and try to run my program, how can I use his login information (username and password) to authenicate against another PC, e.g. using DirectoryEntry object? I have these lines of code, but it needs the user to enter username and password in Textboxes txtUsername and txtPassword respectively. I would like to use the current login...
3
1168
by: SAL | last post by:
Hello, I'm a total asp.net newbie. I'm developing a web app and on my machine I login to a sql server just fine using NT Authentication via the connection string as: Integrated Security=True However, when I try to open the .aspx page from another machine I get the "Login in failed for user NT Authority\Anonymous Logon
2
2357
by: dougloj | last post by:
Hi. I have an ASP.NET application written in C#. To log in, a user must provide their email address and password. I already give the user a "Remember my Email Address" check box. If they check it when logging in, I store the email address in a cookie and automatically display the address when they login again. I now want to give the user a "Remember my Password" checkbox. If they check this new checkbox, I'm planning on encrypting...
6
3240
by: Kat | last post by:
Every time I attempt to run a localhost website, it asks me for a login, as if I am not a user on the local machine. I am a user on the local machine, I am an admin on the local machine. I am not on a network. I have windows xp professional installed, iis is installed and until recently everything worked fine. I am using windows authentication, and have changed everything I can think of to full control, even the Everyone, the vs...
3
4044
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I want to limit the user only login the system one time at the same time. I don't want him login the system two with the same user at the same time. How to do this? If i have a table to record if this user has logined, this user didn't logout and just close IE, how do i set his recoed in the table logout? Thanks, -Billy
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.