473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

User Account test and logon.

Hi Folks,

Im trying to make a little hack that helps users logon to different
servers on several domains.

Now i need to test the password age of a user on a server. I got the
usr/pwd/svr cridentials, but how do i connect to the server with the
cridentials, check the pwd age, and close the connection.

I allready got a change password funtion that works, so all i need now
is to test the age before i call it.

The bonus quistion is as follows:

Some of users need to be loged on permanently to some of the server.
How do i connect to the servers on behalf of the users, and refresh the
connection every hour.

Cheers

Stevns
My source (proof of concept):

namespace poc1
{
class Program
{
[StructLayout(LayoutKind.Sequential, CharSet =
CharSet.Unicode)]
public struct USER_INFO_1
{
public string usri1_name;
public string usri1_password;
public int usri1_password_age;
public int usri1_priv;
public string usri1_home_dir;
public string comment;
public int usri1_flags;
public string usri1_script_path;
}

[DllImport("Netapi32.dll")]
extern static int
NetUserChangePassword([MarshalAs(UnmanagedType.LPWStr)] string
domainname, [MarshalAs(UnmanagedType.LPWStr)] string username,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);

[DllImport("Netapi32.dll")]
extern static int
NetUserGetInfo([MarshalAs(UnmanagedType.LPWStr)] string servername,
[MarshalAs(UnmanagedType.LPWStr)] string username, int level, out
IntPtr bufptr);

static void Main(string[] args)
{
Console.Write("Username:");
string username = Console.ReadLine();

Console.Write("Old Password:");
string oldpwd = Console.ReadLine();

Console.Write("New Password:");
string newpwd = Console.ReadLine();

Console.Write("Server:");
string server = Console.ReadLine();

if (server == "")
{
server = null;
}

if (NetUserChangePassword(server, username, oldpwd, newpwd)
!= 0)
{
Console.WriteLine("Error Changing User Password");
}
else
{
Console.WriteLine("Userpassword changed");
}

Console.WriteLine("Press enter to continue");
Console.ReadLine();

}

}
}

Jun 27 '06 #1
0 966

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

Similar topics

2
by: Brian Madden | last post by:
Hello Everyone, This is sort of a followup to the protecting files question I asked earlier today. I would like to protect a file so that only certain users could download it from my website....
4
by: cmc | last post by:
Hi, I 'm new to DB2 (from Oracle background) and have some fundamental question. In Oracle, you create user account "within the database" to let user to logon to the database. There is no tie...
7
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being...
7
by: John.NET | last post by:
Hi, First please forgive that this is a repost as the first time I didn't have my proper nospam email configured... I'm writing a web service where one method will launch another .NET program...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
1
by: Srinivas Chintakindi | last post by:
Hi All, I am developing one ASP.NET 2.0 application in which user test the remote sql server existance. User enters remote sql server name, data base name, authentication mode, user name,...
0
by: kkos | last post by:
I noticed the following issue posted as a double-hop issue in many discussion boards but found no answers that explain how to pass the second hop with windows auth from IIS ASPX page to remote SQL...
3
by: gderosa | last post by:
I have been getting that dreaded error in my application: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. I have had my application in the test environment, impersonating it using a...
4
by: eruth | last post by:
There are loads of post on this, but nothing that seems to cover my exact problem ;) I have an ASP.Net 1.1 web application running on my local machine. I want to connect to an SQL 2005 server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.