Ejemplo n.º 1
0
        public void SetCredentialOData(string url, string userName, string password)
        {
            DataSource dataSource = new DataSource("OData", url);

            if (userName == null)
            {
                DataSourceSetting dataSourceSetting = new DataSourceSetting("Anonymous");
                CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
            }
            else
            {
                var dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
                CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
            }

            return;
        }
Ejemplo n.º 2
0
        public void SetCredentialSQL(string sql, string userName, string password)
        {
            DataSource dataSource = new DataSource("SQL", sql);

            if (userName == null)
            {
                DataSourceSetting dataSourceSetting = new DataSourceSetting("Windows");
                CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
            }
            else
            {
                var dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
                CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
            }

            return;
        }