943,969 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3761
  • ASP.NET RSS
Nov 4th, 2005
0

Removing prefix XXX\username

Expand Post »
I need to remove the prefix(domain name) if exist in front of a username from a session variable.


paramsql.Value = Session("ssNtUser")

say the domain is za

username is macupryk

I would like to remove the za\ so in the session variable I have

macupryk only but the domain name can change. Also there might not even be a domain name with a slash.


Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mcupryk is offline Offline
14 posts
since Sep 2005
Nov 4th, 2005
0

Re: Removing prefix XXX\username

ASP.NET Syntax (Toggle Plain Text)
  1. string testString = Session("ssNtUser").ToString();
  2.  
  3. int i = testString.IndexOf("\\")+1;
  4. if(i > 0)
  5. {
  6. testString=testString.Substring(i);
  7. }
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Nov 6th, 2005
0

Re: Removing prefix XXX\username

You could also try just running a split command on the string if it contains a backslash.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlexClifford is offline Offline
8 posts
since Jan 2005
Nov 9th, 2005
0

Re: Removing prefix XXX\username

Quote originally posted by mcupryk ...
I need to remove the prefix(domain name) if exist in front of a username from a session variable.


paramsql.Value = Session("ssNtUser")

say the domain is za

username is macupryk

I would like to remove the za\ so in the session variable I have

macupryk only but the domain name can change. Also there might not even be a domain name with a slash.


Thanks.
Hi,

U can use the split method of string object to get the username.

Quote ...
string strUser = Session("ssNtUser") as string;
string[] strTemp = strUser.Split('\\');
if(strTemp.length > 0)
strUser = strTemp[strTemp.length - 1];
paramSql.Value = strUser;
Thanks,
Kedar
Reputation Points: 10
Solved Threads: 1
Light Poster
kedar_challa is offline Offline
47 posts
since Nov 2005
Nov 5th, 2010
0
Re: Removing prefix XXX\username
vb.net : User.Identity.Name.Substring(User.Identity.Name.IndexOf("\") + 1)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
asxcode is offline Offline
1 posts
since Nov 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: video library using asp.net
Next Thread in ASP.NET Forum Timeline: Update EntityDataSource through Ajax Calendar extender





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC