Friday, December 03, 2004

Splitting

Here is a simple code to split the UserName from the Domain Name.

One way of doing this:

string s1 = "GEEK/author";
string s2;
int idx = s1.IndexOf('/');
if (idx != -1)


{ s2 = s1.Substring(idx + 1);}

else
{ // do some error handling}



Here is another version of the same code:


private bool IsAuthenticated()
{

// Here get getIdentity simple returns the "GEEK\author"
int indexValue = getIdentity().IndexOf('\\') + 1;
return getIdentity().Substring(indexValue) == AUTHENTICATEDUSER ? true : false;
}


Here is another way:

if(username.endswith("//author"))
{
// Authenticated
}


No comments: