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

newboe: how to get the user name?

OS: XP pro
IDE VS 2005 .NET
ASP.NET 2.0

System.Security.AccessControl.SecurityInfos.Owner. ToString() returns
domain\username...if the domain is named "TEST" and username is "per" then
this statement returns TEST\per....

But what code must I do if I went to the fullname of the user?

Jeff
May 17 '06 #1
3 1169
Ask the user to put it into a form. ;-)

Seriously, though, if the user is logged in to Active Directory, you should
be able to use the System.DirectoryServices namespace and classes to query
the Active Directory for this information.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jeff" <it************@hotmail.com.NOSPAM> wrote in message
news:un*************@TK2MSFTNGP02.phx.gbl...
OS: XP pro
IDE VS 2005 .NET
ASP.NET 2.0

System.Security.AccessControl.SecurityInfos.Owner. ToString() returns
domain\username...if the domain is named "TEST" and username is "per" then
this statement returns TEST\per....

But what code must I do if I went to the fullname of the user?

Jeff

May 17 '06 #2
Thanks, I'm looking into it now:

System.DirectoryServices.DirectoryEntry de = new
System.DirectoryServices.DirectoryEntry();
string fullname = de.Properties["displayName"].Value.ToString();

This code isn't working because I need to set the de.Path property before
executing the last line.. I'm not sure how to get the domain name the user
is logged into....Any tips would be great....

I've tryed, with out luck using this statment:
string domain = de.Properties["defaultNamingContext"][0];
This statement gives me an error message saying "This domain do not exist"
(or something like that, the error message I get on my computer is in
Norwegian and I translated it into English... I'm a native Norwegian)

What am I doing wrong here?

Any tips would be received with great appreciation!

Jeff
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uK**************@TK2MSFTNGP05.phx.gbl...
Ask the user to put it into a form. ;-)

Seriously, though, if the user is logged in to Active Directory, you
should be able to use the System.DirectoryServices namespace and classes
to query the Active Directory for this information.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jeff" <it************@hotmail.com.NOSPAM> wrote in message
news:un*************@TK2MSFTNGP02.phx.gbl...
OS: XP pro
IDE VS 2005 .NET
ASP.NET 2.0

System.Security.AccessControl.SecurityInfos.Owner. ToString() returns
domain\username...if the domain is named "TEST" and username is "per"
then this statement returns TEST\per....

But what code must I do if I went to the fullname of the user?

Jeff


May 17 '06 #3
Your app will only be able to get AD information about the domain it belongs
to.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jeff" <it************@hotmail.com.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Thanks, I'm looking into it now:

System.DirectoryServices.DirectoryEntry de = new
System.DirectoryServices.DirectoryEntry();
string fullname = de.Properties["displayName"].Value.ToString();

This code isn't working because I need to set the de.Path property before
executing the last line.. I'm not sure how to get the domain name the user
is logged into....Any tips would be great....

I've tryed, with out luck using this statment:
string domain = de.Properties["defaultNamingContext"][0];
This statement gives me an error message saying "This domain do not exist"
(or something like that, the error message I get on my computer is in
Norwegian and I translated it into English... I'm a native Norwegian)

What am I doing wrong here?

Any tips would be received with great appreciation!

Jeff
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uK**************@TK2MSFTNGP05.phx.gbl...
Ask the user to put it into a form. ;-)

Seriously, though, if the user is logged in to Active Directory, you
should be able to use the System.DirectoryServices namespace and classes
to query the Active Directory for this information.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jeff" <it************@hotmail.com.NOSPAM> wrote in message
news:un*************@TK2MSFTNGP02.phx.gbl...
OS: XP pro
IDE VS 2005 .NET
ASP.NET 2.0

System.Security.AccessControl.SecurityInfos.Owner. ToString() returns
domain\username...if the domain is named "TEST" and username is "per"
then this statement returns TEST\per....

But what code must I do if I went to the fullname of the user?

Jeff



May 17 '06 #4

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

Similar topics

2
by: Tom Loach | last post by:
Our system administrator set up an NT server group in order to allow our users to login to our application via https to our sql server. The group appears as a User in SQL Server when you look at...
2
by: Technical Group | last post by:
Friends, Can anybody help me out by sending a piece of C# code showing how to add an active directory user to a particular user group? If the group does not exist, then create it. Thanks in...
15
by: Tom Nowak | last post by:
I am writing a webapp in which a user is required to enter a login id and password on a login form. I have forms authenticaion coded in my web.config. Once the user is logged in, I want to use the...
3
by: Patrick Olurotimi Ige | last post by:
How can i send LOGON_USER or User.Identity.Name to the Database? I'm working on a survey which is intranet based with Windows Authentication. I can get the current user by calling LOGON_USER or...
6
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
4
by: Sylvan | last post by:
I am new with this personalization stuff. Everything was working fine, however, now I always get the Login failed for user ''. The user is not associated with a trusted SQL Server connection....
1
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
1
by: tony | last post by:
Hello! I just want to find out how the system find the name to set on a assembly User control dll. I have done this. 1. Create a user control - Here the namespace was set by the system to...
2
by: John | last post by:
Help! I've just spend the last three days researching and testing the following issue without any results. I have a test page setup to get the Windows logon name of the user. The site is a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.