473,778 Members | 5,590 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 1647
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
4875
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
2972
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
2209
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
4043
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
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
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,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8957
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...
0
6723
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
5370
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
4033
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
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.