Enterprise Library Security Block - security

Does anyone know if there is a way to create the security configuration section via the Enterprise Library API or do we have to use the config wizard / edit by hand?

Yes, you can configure any section via the new fluent interface.
Just use ConfigurationSourceBuilder. Like so:
var builder = new ConfigurationSourceBuilder();
builder.ConfigureSecurity()
.AuthorizeUsingRuleProviderNamed("MyRules")
.SpecifyRule("Rule1", "MyRuleExpression")
.CacheSecurityInCacheStoreNamed("SecCache")
.WithOptions
.UseSharedCacheManager("MyCacheManager")
.SetAsDefault();
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
You even get IntelliSense support.
More info on MSDN

Related

I wrote a Liferay module. How to make it configurable by administrators?

I have created a Liferay 7 module, and it works well.
Problem: In the Java source code I hard-coded something that administrators need to modify.
Question: What is the Liferay way to externalize settings? I don't mind if the server has to be restarted, but of course the ability to modify settings on a live running server (via Gogo Shell?) could be cool provided that these settings then survive server restarts.
More specifically, I have a module for which I would like to be able to configure an API key that looks like "3g9828hf928rf98" and another module for which I would like to configure a list of allowed structures that looks like "BASIC-WEB-CONTENT","EVENTS","INVENTORY".
Liferay is utilizing the standard OSGi configuration. It's quite a task documenting it here, but it's well laid out in the documentation.
In short:
#Meta.OCD(id = "com.foo.bar.MyAppConfiguration")
public interface MyAppConfiguration {
#Meta.AD(
deflt = "blue",
required = false
)
public String favoriteColor();
#Meta.AD(
deflt = "red|green|blue",
required = false
)
public String[] validLanguages();
#Meta.AD(required = false)
public int itemsPerPage();
}
OCD stands for ObjectClassDefinition. It ties this configuration class/object to the configurable object through the id/pid.
AD is for AttributeDefinition and provides some hints for the configuration interface, which is auto-generated with the help of this meta type.
And when you don't like the appearance of the autogenerated UI, you "only" have to add localization keys for the labels that you see on screen (standard Liferay translation).
You'll find a lot more details on OSGi configuration for example on enroute, though the examples I found are always a bit more complex than just going after the configuration.

Netsuite SuiteTalk - Login

I am trying to use SuiteTalk to retrieve customer records.
I downloaded the v2016.1 WSDL from here: http://www.netsuite.com/portal/developers/resources/suitetalk-documentation.shtml
I used mv package to build the WSDL and generated the jar file.
I create a project in Eclipse and added the jar file. I am using Java.
Here's a snippet of my code. I am stuck here and don't know how to proceed. It looks like I am missing another jar file? like the NetSuiteService?
RecordRef role = new RecordRef();
role.setInternalId("3");
role.setType(RecordType.contact);
Passport passport = new Passport();
passport.setEmail("me#test.com");
passport.setPassword("mypassword");
passport.setRole(role);
passport.setAccount("123456");
Please help me. What do I need to do?
I'm not familiar with the Java bindings, but it looks like you are missing the data center URL configuration.
I'd recommend using the ruby bindings. They are community supported and there's some decent example code demonstrating various common functions.
I work with .net, I think you need to initialize the service to indicate the datacenter that corresponds to you, it is more or less like this:
// Instantiate the NetSuite web services
Service = new Aggregates.DataCenterAwareNetSuiteService(_account);
Service.Timeout = 1000 * 60 * 60;
var appInfo = new ApplicationInfo();
//App info from application netsuite
appInfo.applicationId = cuenta.ApplicationInfo;
// Prepare login credentials for request level login
Service.passport = new Passport()
{
email = _email,
password = _password,
account = _account
};
Service.applicationInfo = appInfo;

feature versioning in sharepoint

I've followed following link to implement feature versioning:
http://sisharepoint.wordpress.com/2010/01/21/using-the-featureupgrading-event-to-upgrade-features-sharepoint-2010/
I am new to sharepoint and the requirement is to show the versions of features in my site. Is it possible?I am not able to see the version anywhere in the site. I can see appropriate version in the feature.xml file in feature folder of 14 hive. Just want to know that is it possible to see the versions of each deploy in sharepoint site also?If yes then where can I see it?
Thanks,
Priya
If custom solution fits your requirement then you can try following ways to find activated feature versions.
Use SPFarm.FeatureDefinitions
to get all activated features in the Farm -
SPFeatureDefinitionCollection farmFeatures = SPFarm.Local.FeatureDefinitions;
foreach (SPFeatureDefinition feature in farmFeatures)
{
....
}
To find a version of a particular feature
var spFarm = SPFarm.Local;
System.Version version = spFarm.FeatureDefinitions["YourFeatureName"].Version;
Use SPContext.Current.SiteFeatures or SPContext.Current.Site.Features
var siteFeatures= SPContext.Current.SiteFeatures;
foreach (SPFeature sf in siteFeatures)
{
variable = sf.Definition.DisplayName;
variable = sf.Definition.Version.ToString();
}
4 Use SPContext.Current.WebFeatures or SPContext.Current.Web.Features
var webFeatures= SPContext.Current.WebFeatures;
foreach (SPFeature webFtr in webFeatures)
{
variable= webFtr.Definition.DisplayName;
variable= webFtr.Definition.Version.ToString();
}
Hope this helps.
There's no way to see this in Central Admin or Site Settings. The point is to abstract away versioning from users. Users just know that a specific feature is available, not what version. I agree that it would be nice to actually be able to see this info without having to write a custom solution.

Log in to CRM from ASP.NET

I'm writing an application in which I have to log on to a CRM 2011 server from ASP.NET code. I quickly found this article:
http://msdn.microsoft.com/en-us/library/cc156363.aspx
The problem I'm having is in this bit of code from that article:
//Create the Service
CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.CrmAuthenticationTokenValue = token;
service.Url = crmurl;
Visual Studio can't resolve CrmService. So I tried to add a web reference to this project and point the web reference at the CRM service I'm using. The URL I'm getting from Settings->Customizations in CRM, and I'm using the Organization Service endpoint. However, after I add that reference CrmService is still unresolvable. What am I doing wrong?
First off, you have linked a CRM 4 MSDN article, some things have changed so you might want try this one instead: Authenticate Users with Microsoft Dynamics CRM Web Services.
Then as an alternative you may want to try the CrmConnection class, its a helper library in Microsoft.Xrm.Client. It means you can use a connection string approach to authenticate with CRM (and let the class takes care of all the hard work).
var connection = CrmConnection.Parse("Url=http://crm.contoso.com/xrmContoso; Domain=CONTOSO; Username=jsmith; Password=passcode;");
var service = new OrganizationService(connection);
var context = new CrmOrganizationServiceContext(connection);
You can also keep the connection strings in config files makes life significantly easier.
Related articles:
Simplified Connection to Microsoft Dynamics CRM.
Sample: Simplified Connection Quick Start using Microsoft Dynamics CRM.
If you're using standard AD authentication with a local environment this answer should work fine: How to Authenticate to CRM 2011?
Actually, the login procedure is heavily dependent on the authentication provider you're targeting. I'm currently in the process of structuring that info in a pedagogic way on my blog so you're welcome to check it out and nag if it's too techy.
There are at the moment four such ways.
Active directory
Live id
Federation
Online federation
Which is applicable in your case, you should know already. If not, there's code for that too uploaded just a few days ago.
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
...
public AuthenticationProviderType GetAuthenticationProviderType(Uri address)
{
IServiceManagement<IOrganizationService> organizationServiceManagement
= ServiceConfigurationFactory.CreateManagement
<IOrganizationService>(address);
return organizationServiceManagement.AuthenticationType;
}
Assuming that you're aiming for AD, you're in luck. It's the easiest.
Uri organizationUrl = new Uri("http ... Organization.svc");
OrganizationServiceProxy organizationService = new OrganizationServiceProxy(
organizationUrl, null, null, null);
If you're aiming for Live Id - that's stingy. I'm still trying to set up a graspable example. The ones at MSDN are just too heavy and confusing. At least when one's dense and lazy like me. More info at mentioned but undisclosed location.

Register/ Login/ Membership module in Orchard

I can't figure out how to add Register/Login functionality to a site in Orchard. Is there a Membership module or some configuration I need to enable?
EDIT: What I had in mind were modules along the lines of these that extend the existing User model with registration/profile functionality:
Extended Registration module: http://extendedregistration.codeplex.com/
Orchard Profile module: http://orchardprofile.codeplex.com/
It's under settings/users in the admin ui.
In the Dashboard scroll down to Settings and select Users.
Make sure "Users can create new accounts on the site" is checked and click "Save".
Once this is done log out.
Then click log in, and bellow your username and password field there will be a small text with a blue link to Register.
You don't actually need the extended registration and profile for this. Those are for adding additional information to the registration form.
This can also be done programmatically:
var registrationSettings = _services.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
registrationSettings.UsersCanRegister = true;
However this will not work if you're doing it from Migrations because you won't be able to use WorkContext.
For migrations you can use IRepository for RegistrationSettingsPartRecord:
RegistrationSettingsPartRecord currentSetting = _registrationSettingRepository.Table.First();
currentSetting.UsersCanRegister = true;
_registrationSettingRepository.Update(currentSetting);
However this will no longer work as of Orchard version 1.8 as the record no longer exists. As of 1.8 one way I know of would be using ISiteService:
var site = _siteService.GetSiteSettings();
var regsettings = site.As<RegistrationSettingsPart>();
regsettings.UsersCanRegister = true;

Resources