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

Username in datagrid

Hi all,
I have this problem could I get some help? This code works on a plain
webform and I get user name:
string DomainUser =
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace("\
\","/");
System.DirectoryServices.DirectoryEntry ADEntry = new
System.DirectoryServices.DirectoryEntry("WinNT://"+DomainUser);
Response.Write(ADEntry.Properties["FullName"].Value.ToString());

But When I try it on a datagrid it does not work why is it so? where
would I be going wrong?
myCommand.Parameters.Add(new SqlParameter("@Name",SqlDbType.Text));
myCommand.Parameters["@Name"].Value =
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace("\
\","/");
System.DirectoryServices.DirectoryEntry ADEntry = new
System.DirectoryServices.DirectoryEntry("WinNT://"+st6);
Response.Write(ADEntry.Properties["FullName"].Value.ToString());
I actually get this error: Object reference not set to an instance of
an object.
Thanks.

Mar 28 '07 #1
0 764

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

Similar topics

7
by: Candice | last post by:
Please somebody help! I've deleted my admin username and password which was initially set at test. Now I can't log into my website as the administrator. How do I put Username and Password back so...
11
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are...
14
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the...
8
by: Philip Wagenaar | last post by:
I need to send printjobs to a printqueue under diffrent usernames. The printsoftware on the queue is not very 'secure' so I can create a user on 1 system and send a printjob under it's name to the...
0
by: Sid DeLuca | last post by:
I'm modifying the WSE2 HOL sample to develop my web service. I'm able to get the client application's username token encrypted on the way out (outputTrace.webinfo), but not on receipt from the...
5
by: libra786 | last post by:
I have created a blog and have added a login box which prompts the user for login and id before posting- The username and password have been stored in the database, however when i enter the username...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
24
by: runway27 | last post by:
i have used the following code to validate the username it is working fineif( $username == "" || !preg_match("/^+(?:_+)?$/i", $username) ) { $error.="User name cannot be blank or has special...
2
by: shapper | last post by:
Hello, I know that only authenticated users has a UserName. In Anonymous users there is an ID. If I am not wrong when getting a profile of a user, if the user is authenticated the UserName is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.