Username in datagrid

R

rcoco

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.GetCurrent().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.GetCurrent().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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with network path error! 0
Images in datagrid! 0
Editable datagrid 5
RadioButtonList&Datagrid 0
username 3
multiple insert in access 2
Loop through all AD properties 0
get username using asp.net 2

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top