예제 #1
0
 public OnPremAd(string userName, string password, bool passwordIsDpapiProtected)
 {
     // userName and password are optional
     if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
     {
         _userName = userName;
         _password = GrouperConfiguration.GetSensitiveString(password, passwordIsDpapiProtected);
     }
     _dnCache     = MemoryCache.Default;
     _cachePolicy = new CacheItemPolicy()
     {
         SlidingExpiration = TimeSpan.FromMinutes(30),
     };
 }
예제 #2
0
파일: Exo.cs 프로젝트: Kungsbacka/Grouper
 public Exo(string userName, string password, bool passwordIsDpapiProtected)
 {
     if (string.IsNullOrEmpty(userName))
     {
         throw new ArgumentNullException(nameof(userName));
     }
     if (string.IsNullOrEmpty(password))
     {
         throw new ArgumentNullException(nameof(password));
     }
     string plaintextPassword = GrouperConfiguration.GetSensitiveString(password, passwordIsDpapiProtected);
     SecureString securePassword = new SecureString();
     foreach (char c in plaintextPassword)
     {
         securePassword.AppendChar(c);
     }
     _credential = new PSCredential(userName, securePassword);
 }
예제 #3
0
 public AzureAd(string tenantId, string clientId, string clientSecret, bool clientSecretIsDpapiProtected)
 {
     if (!Guid.TryParse(tenantId, out _))
     {
         throw new ArgumentException(nameof(tenantId), "Argument is not a valid GUID.");
     }
     if (!Guid.TryParse(clientId, out _))
     {
         throw new ArgumentException(nameof(clientId), "Argument is not a valid GUID.");
     }
     if (string.IsNullOrEmpty(clientSecret))
     {
         throw new ArgumentNullException(nameof(clientSecret));
     }
     _clientId     = clientId;
     _clientSecret = GrouperConfiguration.GetSensitiveString(clientSecret, clientSecretIsDpapiProtected);
     _authorityUri = new Uri($"https://login.microsoftonline.com/{tenantId}");
 }