473,670 Members | 2,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

14 and 15

Dumb questions 14 and 15 ...

14 How to I access the User Name in C#?
15 How do I access the Organization Name in C#?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Nov 16 '05 #1
5 1139
to get current user name,

WindowsIdentity .GetCurrent().N ame
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Thom Little" <th**@tlanet.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Dumb questions 14 and 15 ...

14 How to I access the User Name in C#?
15 How do I access the Organization Name in C#?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Nov 16 '05 #2
Hi Thom,

Based on my understanding, you want to certain user account's user name and
organization name in C#.

There are many ways to get a user account's name, such as:
1. Using WMI to query Win32_UserAccou nt class's Name or FullName property.
2. Using WindowsIdentity .GetCurrent().N ame property(Just as Jiachuan
stated)

I think the second way is much easier for you.

To access the Organization name, I think you should get it through ADSI.

First, you may get the your user account's DirectoryEntry object, then you
can refer the "Organizati on Name" through "Organizati on" attribute. Because
"Organization"' s displayname is "o", you can just do like this:

DirectoryEntry usr =new DirectoryEntry( "LDAP://CN=New
User,CN=users,D C=fabrikam,DC=c om");
string val = (string) usr.Properties["o"].Value;

For more sample and information, please refer to:
http://msdn.microsoft.com/library/de...us/sds/sds/use
r_management.as p

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #3
Hi Thom,

Does my reply make sense to you? Do you still have any concern on this
issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #4
I found ...
this.lblUser.Te xt = SystemInformati on.UserName ;
.... it is REAL simple.
Your suggestion for Organization eludes me. I tried ...
using System.Director yServices ;
.... and was informed that
DirectoryServic es does not exist in the System namespace.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:iG******** ******@cpmsftng xa10.phx.gbl...
Hi Thom,

Based on my understanding, you want to certain user account's user name and organization name in C#.

There are many ways to get a user account's name, such as:
1. Using WMI to query Win32_UserAccou nt class's Name or FullName property.
2. Using WindowsIdentity .GetCurrent().N ame property(Just as Jiachuan
stated)

I think the second way is much easier for you.

To access the Organization name, I think you should get it through ADSI.

First, you may get the your user account's DirectoryEntry object, then you
can refer the "Organizati on Name" through "Organizati on" attribute. Because "Organization"' s displayname is "o", you can just do like this:

DirectoryEntry usr =new DirectoryEntry( "LDAP://CN=New
User,CN=users,D C=fabrikam,DC=c om");
string val = (string) usr.Properties["o"].Value;

For more sample and information, please refer to:
http://msdn.microsoft.com/library/de...us/sds/sds/use r_management.as p

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #5
Hi Thom,

Thanks very much for your feedback.

Yes, there are a lot of ways to retrieve the user name.
SystemInformati on.UserName is really simple :-)

To use ADSI, you should use System.Director yServices namespace in .Net.
This namespace is not included in the default assembly, you have to add
this assembly into current project through "Add Reference":

In IDE, select "Reference" node of your project in Solution Explorer. Then,
right click this node and select "Add Reference". Then, you can add
"System.Directo ryServices.dll" in ".Net" tab.

Also, I want to inform you that not all the user has organization
information. It may be empty. You can view certain user account's
organization information in the domain through ADSI Edit tool.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #6

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

Similar topics

3
11209
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how to send data via POST over https and recieve data from the Authorize.net server over an https...
2
5804
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
22996
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8462
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
0
8386
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
8815
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...
1
8592
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
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
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
6216
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
5686
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();...
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
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.