internal NameValuePair ReplacePasswordPwd(out string constr, bool fakePassword)
{
bool expanded = false;
int copyPosition = 0;
NameValuePair head = null, tail = null, next = null;
StringBuilder builder = new StringBuilder(_usersConnectionString.Length);
for (NameValuePair current = _keyChain; null != current; current = current.Next)
{
if ((KEY.Password != current.Name) && (SYNONYM.Pwd != current.Name))
{
builder.Append(_usersConnectionString, copyPosition, current.Length);
if (fakePassword)
{
next = new NameValuePair(current.Name, current.Value, current.Length);
}
}
else if (fakePassword)
{
// replace user password/pwd value with *
const string equalstar = "=*;";
builder.Append(current.Name).Append(equalstar);
next = new NameValuePair(current.Name, "*", current.Name.Length + equalstar.Length);
expanded = true;
}
else
{
// drop the password/pwd completely in returning for user
expanded = true;
}
if (fakePassword)
{
if (null != tail)
{
tail = tail.Next = next;
}
else
{
tail = head = next;
}
}
copyPosition += current.Length;
}
Debug.Assert(expanded, "password/pwd was not removed");
constr = builder.ToString();
return head;
}