public SafeFreeNegoCredentials(bool isNtlmOnly, string username, string password, string domain) : base(IntPtr.Zero, true) { Debug.Assert(username != null && password != null, "Username and Password can not be null"); const char At = '@'; const char Backwhack = '\\'; // any invalid user format will not be mnipulated and passed as it is. int index = username.IndexOf(Backwhack); if (index > 0 && username.IndexOf(Backwhack, index + 1) < 0 && string.IsNullOrEmpty(domain)) { domain = username.Substring(0, index); username = username.Substring(index + 1); } // remove any leading and trailing whitespace if (domain != null) { domain = domain.Trim(); } username = username.Trim(); if ((username.IndexOf(At) < 0) && !string.IsNullOrEmpty(domain)) { username += At + domain; } bool ignore = false; _isNtlmOnly = isNtlmOnly; _userName = username; _isDefault = string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password); _credential = SafeGssCredHandle.Create(username, password, isNtlmOnly); _credential.DangerousAddRef(ref ignore); }
public SafeFreeNegoCredentials(string username, string password, string domain) : base(IntPtr.Zero, true) { bool ignore = false; _credential = SafeGssCredHandle.Create(username, password, domain); _credential.DangerousAddRef(ref ignore); }