473,585 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Information about the current logged user !

Hey guys,

small question. Can I find out if the current logged on use is a local
user or a domain user ?
And please don't use any solution that uses String parsing...

What I need is to get the display name of the current user and the
only way I'm able to do this is using a DLL wrapper :

[DllImport("secu r32.dll", CharSet=CharSet .Auto)]
public static extern int GetUserNameEx (int nameFormat,
StringBuilder userName, ref int userNameSize);

But is there no .Net code available ??

Greets
Glenn

Sep 5 '07 #1
3 1932
"Depechie" <gl************ ***@gmail.comwr ote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
Hey guys,

small question. Can I find out if the current logged on use is a local
user or a domain user ?
And please don't use any solution that uses String parsing...

What I need is to get the display name of the current user and the
only way I'm able to do this is using a DLL wrapper :

[DllImport("secu r32.dll", CharSet=CharSet .Auto)]
public static extern int GetUserNameEx (int nameFormat,
StringBuilder userName, ref int userNameSize);

But is there no .Net code available ??

Greets
Glenn

Get the MACHINE (System.Environ ment.MachineNam e) name and DOMAINNAME
(System.Environ ment.UserDomain Name) from the environment, if both are equal,
you are running in a local logon session, else you are running in a domain
session with DOMAINNAME as the logon domain.

Willy.

Sep 5 '07 #2
On Sep 5, 6:54 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
"Depechie" <glenn.versweyv ...@gmail.comwr ote in message

news:11******** **************@ g4g2000hsf.goog legroups.com...
Hey guys,
small question. Can I find out if the current logged on use is a local
user or a domain user ?
And please don't use any solution that uses String parsing...
What I need is to get the display name of the current user and the
only way I'm able to do this is using a DLL wrapper :
[DllImport("secu r32.dll", CharSet=CharSet .Auto)]
public static extern int GetUserNameEx (int nameFormat,
StringBuilder userName, ref int userNameSize);
But is there no .Net code available ??
Greets
Glenn

Get the MACHINE (System.Environ ment.MachineNam e) name and DOMAINNAME
(System.Environ ment.UserDomain Name) from the environment, if both are equal,
you are running in a local logon session, else you are running in a domain
session with DOMAINNAME as the logon domain.

Willy.
Hey Brian and Willy,

So there is no function that actually tells me if it is a domain user
or not ?
Because I also saw the difference in DomainName and MachineName, but
that is also String checking.

But ok, if that is the only way to go, then I was on the correct
track !
Weird that .Net doesn't provide this information !! Because Windows
needs it when you start up your pc, so somehow it has to know where
the user is !
Strange....

But thanks for the nice answers

Sep 5 '07 #3
>
So there is no function that actually tells me if it is a domain user
or not ?
Because I also saw the difference in DomainName and MachineName, but
that is also String checking.
Gosh, I thought Willy gave a very elegant solution.

>
But ok, if that is the only way to go, then I was on the correct
track !
Weird that .Net doesn't provide this information !! Because Windows
needs it when you start up your pc, so somehow it has to know where
the user is !
I suspect Windows does something very similar to what Willy describes.

Brian

Sep 5 '07 #4

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

Similar topics

1
8115
by: Rudolf Bargholz | last post by:
Hi, DB2 v7.1 FP3 on Windows 2003 I am trying to acheive the following: create trigger ADD_LHL after insert on MAINTABLE for each row mode db2sql insert into LOGTABLE
1
2559
by: amwi | last post by:
I have tried to find a solution on this problem "everywhere" without any luck. I am writing a service to track the time that the current logged on interactive user is using the computer. Perhaps one of you experts out there can point me in the right direction? Thank you for any help!
3
1557
by: Bart | last post by:
I want to get the current username (or other information) about the user who is currently logged on in the windows 2000 domain. I thought about user.identity.name, but it returns an empty string. Any suggestions ?
6
4592
by: John Dalberg | last post by:
I want to automate the process of logging into an intranet. I want to pull out the username of the Windows user logged into the machine running the browser and use the username in my app. How can I get the logged in username? Do I have to disable the anonymous access in IIS? I rather not because the site is running under a certain domain...
10
3229
by: madereal | last post by:
Situation: I have a database that has users with different levels of access to the information they are allowed to view. I have addressed this issue by creating a login form that opens on startup. Behind this form is the tblUserDetails, which has login information such as: userID, password and access level (which has three levels:...
17
1441
by: Gerrit | last post by:
Hallo, In my application, the user must logon with a username and a password. In all the tables in my database, there is a field user. By saving new or changed records, the username is writed to that field. Now I have a class Session with the User-information. By opening the program, I have code like this on the mainform: Session sess...
3
2172
by: daokfella | last post by:
I want to be able to store profile information for a user when they sign up for an account...but BEFORE they can log in. Can this be done using any of the built-in profile methods? Here's my current sign-up procedure: 1. User creates an account with username, password, e-mail and other information that I want to store in profile. 2....
5
2189
by: Charles May | last post by:
Anyone have a simple concept for the best way to store timeclock information in a database. I currently have my table set up like this with a typical daily entry. tcID empID Type Date Time 1 37 'Clockin' 1/18/08 7:45:39 AM 2 38 'Clockin' 1/18/08 7:55:42 AM 3 ...
0
2112
by: thephatp | last post by:
Is there any possible way to get the currently logged in (active) user from within a service? I need the service to start at runtime. I need to capture log on / log off / switch user events. I haven't gotten to that yet, but it IS possible from within a windows service, correct? I figured I'd ask because of my current problem. Line of...
0
7908
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...
0
7836
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...
0
8199
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. ...
0
8336
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...
1
7950
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...
0
6606
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...
0
3835
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...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1175
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...

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.