473,395 Members | 1,870 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,395 software developers and data experts.

Why does the .NET report the old name of the account??

A month ago I had to re-install Win XP (Home version). I did not give my
name to the installing program, so it created a default account called
"Owner" with administrator privileges.

Later I changed the account name to correspond my real name. Now it is
shown correctly both in the start menu and in the login screen.

But I still get the old name ("Owner") if I call any of these:

- SystemInformation.UserName
- System.Security.Principal.WindowsIdentity.GetCurre nt().Name
- System.Environment.UserName

How do you fix this?
Nov 17 '05 #1
5 954
When an Windows Account is first setup, it is given a 'Name', which
can't be changed.

When you 'change' the user name for the Welcome Screen and Start Menu,
windows updates the users 'Real Name' (I think it's called), and uses
this.

The WindowsIdentity class doesn't seem to have the Real Name though :(

I've had a quick look, but can't find anything else that might return
it, but it has to be possible if Windows can do it.

Nov 17 '05 #2
raican wrote:
I've had a quick look, but can't find anything else that might return
it, but it has to be possible if Windows can do it.


Yep. That seems plausible. If you (or somebody else) find it, please
tell me!

I think this makes the user identification in some cases somewhat
untrustworthy.

Nov 17 '05 #3
Slight mistake... It's called Fullname, not Real Name. Sorry, my bad.

Have a look at 'Win32_UserAccount' on the MSDN (msdn.microsoft.com) it
has the Fullname. How to get at it, i'm not sure yet. I'll have a look
when i get home (at work atm (shhh, don't tell)), and i'll post any
code i come up with. :)

hope this helps

Nov 17 '05 #4
Well, here goes nothing...

// Copy From Here...
using System;
using System.Management;

class User
{
[STAThread]
static void Main(string[] args)
{
SelectQuery q = new SelectQuery();

q.ClassName = "Win32_UserAccount";
q.Condition = "Name = \"" + System.Environment.UserName + "\"";

Console.WriteLine(q.QueryString);

ManagementObjectSearcher s = new ManagementObjectSearcher(q);
foreach(ManagementObject o in s.Get())
Console.WriteLine("Full Username - {0}", o["FullName"]);

Console.ReadLine();
}
}
// ... To Here.

This worked for me, hope it helps

Nov 17 '05 #5
raican wrote:
Well, here goes nothing...

This worked for me, hope it helps


Great! Thanks for the effort.

PC
Nov 17 '05 #6

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

Similar topics

0
by: Yasin | last post by:
Hi I have one reports which shows the Account wise daily transaction during the day.(pl's find below report layout format with column description) May or may not be each account have multiple...
24
by: Michael Malinsky | last post by:
I'm attempting to create a database which will take information from one (perhaps two) tables and utilize that information to return queries to a report designed in Excel. The general idea I...
3
by: AstrA | last post by:
Hi All Wondered if you could help. Basically I have 2 tables that contain all the data I want for my report, but I need to put it in a particular way and I need to display it in an ASP page...
0
by: jojo | last post by:
Hi - I have created a dataset (ds with name 'Account'), and added a table (also named 'Account') to it. Then I report.SetDataSource(ds); When I test report.IsLoaded, I get a true response. But...
4
by: Graham | last post by:
I'd like to automate delivery of new Report objects to my users (note: NOT published reports -- the report *objects* themselves.) I could fairly easily write code to capture the appropriate...
4
by: Miguel | last post by:
I have synchronized combo boxes linking Account Type with Customer Names based on the template that Microsoft has in one of its samples databases. There are the appropriate relationships between...
4
by: billelev | last post by:
Hello. I have a report that displays the following information. Accounts StockName (Accounts can have many StockNames, and multiple instances of a StockName) CashInvested (Each StockName has...
1
by: dfw1417 | last post by:
I have used a query and report filter to return records related to a specific account id. I want to print a report including only the latest 6 records out of the set returned by the record filter. I...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
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,...

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.