Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I capture the WINDOWS USERNAME included to my below code?

Tags:

c#

asp.net

private void UndeletableComments(LinqDataSourceUpdateEventArgs e)
{
    //get a reference to the currently saved item ****NOTE (State) is the ClassName. It’s a table of states in this test database
    var currentData = ((MyData)e.OriginalObject).Notes;

    // make a copy of whatever is in the edit field and strip out the previous comments
    var newData = ((MyData)e.NewObject).Notes.Replace(currentData, string.Empty);

    //check both values for nulls
    if (currentData != null && newData != null)
    {
        newData = ((MyData)e.NewObject).Notes.Replace(currentData, string.Empty);
    }

    // replace the data to be stored in the database with the currentdata + the newData 
    // I added a datestamp to see when the new comment was added.
    ((MyData)e.NewObject).Notes = string.Format("{0} Added:{1} at (2) --- {3}", currentData, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), newData);


    // I need to see the WINDOW USERNAME by capturing who added a new comments
like image 203
Yves Avatar asked Feb 03 '10 16:02

Yves


1 Answers

see the Environment.UserName

Console.WriteLine("UserName: {0}", System.Environment.UserName);
like image 86
serhio Avatar answered Nov 14 '22 23:11

serhio