Removing prefix XXX\username

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2005
Posts: 14
Reputation: mcupryk is an unknown quantity at this point 
Solved Threads: 0
mcupryk mcupryk is offline Offline
Newbie Poster

Removing prefix XXX\username

 
0
  #1
Nov 4th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Removing prefix XXX\username

 
0
  #2
Nov 4th, 2005
  1. string testString = Session("ssNtUser").ToString();
  2.  
  3. int i = testString.IndexOf("\\")+1;
  4. if(i > 0)
  5. {
  6. testString=testString.Substring(i);
  7. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 8
Reputation: AlexClifford is an unknown quantity at this point 
Solved Threads: 0
AlexClifford AlexClifford is offline Offline
Newbie Poster

Re: Removing prefix XXX\username

 
0
  #3
Nov 6th, 2005
You could also try just running a split command on the string if it contains a backslash.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 47
Reputation: kedar_challa is an unknown quantity at this point 
Solved Threads: 1
kedar_challa's Avatar
kedar_challa kedar_challa is offline Offline
Light Poster

Re: Removing prefix XXX\username

 
0
  #4
Nov 9th, 2005
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.

string strUser = Session("ssNtUser") as string;
string[] strTemp = strUser.Split('\\');
if(strTemp.length > 0)
strUser = strTemp[strTemp.length - 1];
paramSql.Value = strUser;
Thanks,
Kedar
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2599 | Replies: 3
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC