public ISecretServerClient GetClient(SecretServerContext context) { ConfigurationManager.AppSettings["SecretServerSdkConfigDirectory"] = context.SdkConfigDirectory; var client = new SecretServerClient(); client.Configure(new ConfigSettings { SecretServerUrl = context.SecretServerUrl, RuleName = context.RuleName, RuleKey = context.RuleKey, CacheStrategy = CacheStrategy.Never, ResetToken = context.ResetToken, }); return(client); }
static void DemonstrateSdkFunctionality(IConfigurationSection config) { Log.Debug("Thycotic Secret Server Constrcutor"); var client = new SecretServerClient(); Log.Debug("Loading Configuration from Config Section"); var sdkConfig = new { Uri = config.GetValue <string>("Uri"), RuleName = config.GetValue <string>("RuleName"), RuleKey = config.GetValue <string>("RuleKey"), CacheAge = config.GetValue <int>("CacheAge"), ResetToken = Path.GetRandomFileName().Replace(".", string.Empty) }; Log.Debug($"Loaded Configuration: \n{JsonConvert.SerializeObject(sdkConfig, Formatting.Indented)}"); Log.Debug("Configuring Thycotic SecretServerClient"); client.Configure(new ConfigSettings { SecretServerUrl = sdkConfig.Uri, RuleName = sdkConfig.RuleName, RuleKey = sdkConfig.RuleKey, CacheStrategy = CacheStrategy.CacheThenServerAllowExpired, CacheAge = sdkConfig.CacheAge, ResetToken = sdkConfig.ResetToken }); Log.Debug("Thycotic Secret Server Client Initialized"); var templateName = config.GetValue <string>("SecretTemplateName"); var searchText = config.GetValue <string>("SearchText"); var secretId = SearchSecretId(client, sdkConfig.Uri, templateName, searchText); var secret = client.GetSecret(secretId); foreach (var item in secret.Items) { Log.Debug($"{item.Slug}: {item.ItemValue}"); } }