private bool AreCredentialsExplicit(ADSessionInfo info) { if (info == null) { return(false); } else { return(ADPasswordUtils.AreCredentialsExplicit(info.Credential)); } }
public static bool MatchCredentials(PSCredential cacheCred, PSCredential userCred) { if (!ADPasswordUtils.MatchPassword(cacheCred.Password, userCred.Password)) { return(false); } else { return(string.Equals(cacheCred.UserName, userCred.UserName, StringComparison.OrdinalIgnoreCase)); } }
private ADSessionCache.CacheEntry FindEntryInServerList(string key, ADSessionInfo info, out int index) { List <ADSessionCache.CacheEntry> cacheEntries = null; ADSessionCache.CacheEntry item = null; int num; index = -1; if (ADSessionCache._sessionMap.TryGetValue(key, out cacheEntries)) { if (DebugLogger.Level >= DebugLogLevel.Info) { object[] count = new object[4]; count[0] = "FindEntryInServerList: Found "; count[1] = cacheEntries.Count; count[2] = " session(s) in cache with key: "; count[3] = key; DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat(count)); } bool flag = this.AreCredentialsExplicit(info); WindowsIdentity current = null; if (!flag) { current = WindowsIdentity.GetCurrent(true); } int i = 0; bool flag1 = false; for (i = 0; i < cacheEntries.Count; i++) { item = cacheEntries[i]; if (item.Session.MatchConnectionOptions(info)) { bool flag2 = ADPasswordUtils.AreCredentialsExplicit(item.Credential); if (!flag || !flag2) { if (!flag && !flag2) { if (current != null || !(null == item.ImpersonatedOwnerSid)) { if (current.Owner == item.ImpersonatedOwnerSid) { flag1 = true; break; } } else { flag1 = true; break; } } } else { if (ADPasswordUtils.MatchCredentials(item.Credential, info.Credential)) { flag1 = true; break; } } } else { if (DebugLogger.Level >= DebugLogLevel.Info) { DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Connection options did NOT match with session ", item.Session.SessionInfo.Server)); } } } if (!flag1) { if (DebugLogger.Level >= DebugLogLevel.Info) { DebugLogger.LogInfo(ADSessionCache._debugCategory, "FindEntryInServerList. Could NOT find a matching cached session entry"); } } else { if (DebugLogger.Level >= DebugLogLevel.Info) { DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList. Found a cached session entry: ", item.Session.SessionInfo.Server)); } } int numPointer = index; if (flag1) { num = i; } else { num = -1; } numPointer = num; if (flag1) { return(item); } else { return(null); } } else { if (DebugLogger.Level >= DebugLogLevel.Info) { DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Could NOT find a session in cache with key: ", key)); } return(null); } }