Solved

Split and get rid of

Posted on 2010-09-02
4
294 Views
Last Modified: 2013-12-17
I captured the windows Identity and need to take off the domain name before I write it to the database.
The results of the following code are DOMAIN\r3nder - I need it to be just r3nder
I am sure its easy I just cant find the way to Split it

WindowsIdentity currIdentity = WindowsIdentity.GetCurrent();
string NtAccountName = currIdentity.Name;

Open in new window

0
Comment
Question by:r3nder
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 33588492

string NtAccountName = currIdentity.Name.Substring(currIdentity.Name.IndexOf("\\") + 1);

Open in new window

0
 
LVL 7

Expert Comment

by:mquiroz
ID: 33588545
or something like:

NtAccountName.Split('\\')[1]
0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 33588582
you are the bomb Kaufmed = as usual!!!
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33588963
Glad to help...   as usual   :D
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question