Commerce Server 2007: Development Tip #8 – UpmRoleProvider


I’m going to repost this series of “development tips” related to Commerce Server 2007 to help other folks get started with their development work. All of these “tips” come directly from what I’ve learned (the hard way) over the past eight months and are intended to save you time and effort. All code samples are now based upon the RTM version and have been tested in our production environment.


CS2007 now offers a custom ASP.NET 2.0 compatible membership provider (UpmMembershipProvider) for authentication and authorization. What’s still lacking however, is a custom role provider which is essential for most B2B scenarios. Finding this feature absent from the CTP and Beta builds, I did what any red-blooded American developer would do, I built it myself!


[Well almost by myself. I did get a ton of preview documentation from Brian Goldfarb and a role provider template from Joshua Flanagan, but I wrote almost ten lines of code myself to get it to work. That counts. Doesn’t it? (LOL)]


The source code to the Commerce Server 2007 UpmRoleProvider can be downloaded here.


The “heart” of the code is shown below and it’s amazingly simple to implement thanks to the new “Provider” model used by ASP.NET 2.0. I use the Commerce Server UserObject Profile to store the user’s “role” as the weakly-typed profile property GeneralInfo.user_role.


public override string[] GetRolesForUser(string username)
    {
        // Throw an exception if the username is null or empty
        verifyParameter(username, “username”);
 
        // Get the User Profile of the person currently logged in.
        Profile userProfile = CommerceContext.Current.ProfileSystem.GetProfile(“email_address”, username, “UserObject”);
 
        // Get the User Role value from the customer property in the modified UserObject profile
        string userrole = userProfile.Properties[“GeneralInfo.user_role”].Value.ToString();
 
        // Return an empty string array if the User Role property was not set
        if (String.IsNullOrEmpty(userrole))
        {
            return new string[] { “” };
        }
        // else return the User Role in a string array
        return new string[] { userrole };        
    }

To make this work, you add the UpmRoleProvider.cs class file to your Commerce Server web site’s App_Code folder and add the following to it’s Web.Config file.


In any site sub-folder that you wish to limit access to a certain role (such as the “Admin” role) you simply add the following code to it’s Web.Config.


The really cool thing about this is how it automatically enables SiteMap Security Trimming as I posted about several months ago. The result is pretty cool. If you belong to the “Admin” role, you can “see” all the menu choices as shown below.


If you belong to the “Normal User” role, you only “see” the appropriate menu choices as shown here.


Download the sample code and give it a try in your Commerce Server 2007 B2B site and let me know what you like and don’t like.


Special thanks to Brian Goldfarb and Joshua Flanagan for their guidance and sample code.


Technorati Tags: Commerce Server

Share this post: Email it! | bookmark it! | digg it! | reddit!| kick it!

BizTalk 2004: HAT: How to select all Messages/Service Instances

BizTalk 2004: HAT: Select all Messages/Service Instances

 

Sometimes I need to select all Messages/Service Instances in HAT, “Operations/Messages…(or Service Instances…)” window then terminate them. When I tried to use the mouse by “hold left button – drag over all records” I’m not in luck. As I’ve tried to use “click the first record (cell) – hold Shift and click the last record (cell)” I’m not in luck too.
All these methods work only on the visual part of list. On the big list I have to use one of this method a lot of times, scrolling down the list after each cycle.

 

But there is a “secret” method!
If you place the cursor on the line divided the header of the list from the list body, the cursor changes the form to the “down-arrow“. Click the mouse and, that’s it, the whole list is selected!


 


I wander why the Microsoft guys like to brake the “Microsoft Compatibility” rules in BizTalk so many times? They’ve invented new GUI features, wow.
I’ve taken only one example but have many.

 


 

New SAP Content…

Developer Productivity Study: Comparing Microsoft BizTalk Server 2006 to SAP XI for Integrating Heterogeneous Systems (Download)


Today’s business applications not only run on a number of different platforms, they are often implemented in a variety of programming languages, running on multiple operating systems. To meet these demands, enterprise developers are progressively merging systems and infrastructure into comprehensive integration suites by relying on service-oriented architectures (SOA) that make integration possible at a lower total cost of ownership (TCO).


Microsoft engaged Crimson Consulting Company, a leading provider of consulting services to the high technology industry, to conduct a comparative study of developer productivity with integration servers Microsoft%u00ae BizTalk%u00ae Server 2006 and SAP XI 3.0, using mySAP%u2122 ERP in heterogeneous environments. The study was conducted in collaboration with Intelligroup, one of the leading SAP integrators.


This paper explains Crimson’s methodology and results of their study.


BizTalk Server 2006 Labs (Download)


These labs demonstrate Microsoft%u00ae BizTalk%u00ae Server 2006 capabilities by integrating various heterogeneous applications and systems in a business-to-business (B2B) environment.


The package contains the following documents with supporting code:



  • Lab Prerequisites.doc

  • Lab Scenario 1 – Send Messages from BTS 2006 to SAP System.doc

  • Lab Scenario 2 – Receive Messages from SAP System to BTS 2006.doc

  • Lab Scenario 3 – Send and Receive Messages from BTS 2006 to SAP System Synchronously.doc

BAM Portal Activity Search: "This action cannot be performed because one or more database(s) appears corrupted"

When using the BAM Portal Activity Search feature, you may be directed to an error page with the above error message.
This error message means that there are instances with duplicate ID in the activity you were searching. If you look at the “Application” event log on the computer which runs the BAM Web Services, you will find one entry from “BAM Web Service” comparable to the following:
EXCEPTION:System.Web.Services.Protocols.SoapException: There are instances with duplicate ID ‘PO_COMPLETED_100’…(read more)

Serialization in Windows Communication Foundation

Next time you stop by the Service Station, you’ll find my latest column. It’s titled Serialization in Windows Communication Foundation. It compares the ins-and-outs of the three supported WCF serializers –XmlSerializer, DataContractSerializer, and NetDataContractSerializer — including the differences in their respective programming models and XML mapping algorithms. Enjoy.

VPC free download; Vista EE 4 VM rights; Interested in a Virtual Role?

The last 6 months have been a lot of fun. On the downside I’ve attended exactly zero conferences – ok my wife doesn’t think that’s a downside.  On the upside I’ve been working in areas I haven’t had the opportunity to over the past 5 years.  Specifically I’ve been thinking about hardware virtualization and application virtualization. Some of that thinking is becoming real :).


For example, today we announced that Virtual PC 2004 SP1 is a free product. Go ahead and use it for any scenario you want.  The download is available already from www.microsoft.com/virtualpc


We also announced the first of our licensing changes to internalize virtualization into Windows Vista.  Specifically customers who buy first software assurance and then deploy either Vista Enterprise  or Ultimate can install 4 copies of the OS in a VM in addition to the copy on the physical machine for the cost of one license.  This is similar to an existing right we have on Windows Server Enterprise.  This right is for one user on one device and is good for application compatibility scenarios.  Download VPC, create up to 4 VMs for various previously incompatible applications and get going. 


Additionally we announced Virtual PC 2007 which will support Windows Vista and be available shortly thereafter.


We are starting to think about future virtualization scenarios for Windows so if you have something you want us to do drop me a line.


Finally, I’m hiring up a small team within Windows to help us think more deeply about virtualization and drive innovation in the space from a business model, marketing, and product planning perspective. If you are interested and skilled then drop me a line.  The job descriptions are here.

MSBuild tasks now available for BizTalk Projects

Several people have asked me about support for MSBuild within BizTalk projects. So I’m happy to see that our team in the UK has just released some MSBuild tasks for BizTalk 2006. They are availalbe on GotDotNet.


 


(http://www.gotdotnet.com/codegallery/codegallery.aspx?id=b4d6499f-0020-4771-a305-c156498db75e ).


 


There are tasks to do the following:


 


Export a current system to an MSBuild proj file.


Application

























AddReferences


Adds a reference to an application


Create


Creates an application


Delete


Deletes an Application, and all its child objects


Exists


Checks if an application exists


RemoveReferences


Removes a reference from an application


Start


Starts an application


Stop


Stops an application


Assembly



















Deploy


Deploys an assembly into BizTalk.


Exists


Checks whether an assembly is deployed in a BizTalk installation.


ExportBindings


Exports the bindings of an assembly in BizTalk to an XML file.


ImportBindings


Imports the bindings of an assembly into BizTalk from an XML file.


Undeploy


Undeploy an assembly from BizTalk.


 


Orchestration




























Bind


Binds an orchestration


Enlist


Enlists the given instance of the BizTalk Orchestration.


Exists


Checks if an Orchestration exists in an assembly in BizTalk Server.


Start


Starts the given instance of the BizTalk Orchestration.


Stop


Stops the given instance of the BizTalk Orchestration.


TerminateInstances


Terminates any running instances of the BizTalk Orchestration.


UnBind


Unbind an orchestration


UnEnlist


UnEnlists the given instance of the BizTalk Orchestration.


 


ReceiveLocation










Configure


Configures a receive location


Exists


Checks if it exists


 


ReceivePort






















AddReceiveLocation


Adds a receive location to this port


Configure


Configures a receive port


Create


Creates a receive port


Delete


Deletes a receive port


Exists


Checks if it exists


RemoveReceiveLocation


Removes a receive location


 


SendPort




























Configure


Configures a send port 


Create


Creates a send port


Delete


Deletes a send port


Enlist


Enlists a send port


Exists


Checks if it exists


Start


Starts a send port 


Stop


Stops a send port


UnEnlist


Unenlists a send port


 


SendPortGroup


































AddSendPort


 Adds a send port to an existing send port group


Configure


Configures a send port group


Create


Creates a send port group


Delete


Deletes a send port group


Enlist


Enlists a send port group


Exists


Checks if it exists


RemoveSendPort


Removes a send port from the send port group


Start


Starts the group


Stop


Stops the group


UnEnlist


Unenlists the group


 


 


There are also 2004 tasks in the same assembly for those of you that don’t know they are there.


 


Cheers and keep on BizTalking

People Ready Process with BPM and BizTalk

“People-Ready Process Through Business Process Management (BPM).” That’s our just-articulated vision for BPM using
Microsoft technologies. We see BPM not as just a technology solution, but something Gartner calls a “management discipline.” However,
we’re claiming that the Microsoft stack can get you through the four main phases of BPM (model/design –> develop/deploy –> manage/interact –>
analyze/optimize).

Now I’m not here to regurgitate a press release. What is this REALLY? This is NOT a product launch announcement with regards to BizTalk
functionality. We’re pretty much turning the spotlight on the ways to build flexible, dynamic processes using Microsoft
software like Office (Office Business Applications), SharePoint, BizTalk, WinFx and partner software.

So, first check out our new BPM site, and register for the BPM webcast
(
Enabling “People-Ready Processes” Using Microsoft Business Process Management Solutions and Technologies
).

So what do I care about here personally? I think that of the 4 phases above, that at this moment, our software does 3 of them quite
well. Our development toolset is unparalleled (IMHO), our management options are increasingly solid, and our analysis story
is top-notch (especially with the ProClarity acquisition). I think our process modeling toolset and business rule design isn’t quite
complete, so what I care about is the slew of integrated partner offerings we highlighted today. A few of them
are remarkably promising. These solutions from 3rd parties integrate tightly with BizTalk and the Rules Engine to fill in the gaps
of the current Microsoft stack. I summarize each here …

Rules Engine Enhancements

  • InRule. Nice offering. Has check in/out capabilities. Also allows you to label and
    version your rule sets. Capabilities like decision tables, currently missing from the MS BRE. You’ve got testing and flow
    visualization abilities, reports for difference checking. I ALWAYS get asked about that in the MS BRE!
  • RuleBurst. I’m VERY impressed by this software. Allows you to optionally write
    your rules in the Office environment (Excel, Word, Visio) and then analyze them in their development studio. Lots of reports
    available and visual representations of the rule set. You’ve got regression testing (HUGE!) and test case generation. You
    can then export your rules to the BRE’s BRL format, and them import them into the MS Rules Engine.

Process Modeling

  • itp commerce. I know this software has been used on BizTalk projects in the past, so
    it’s got a track record with us. You’ve got a BPMN supported modeler and designer, documentation generation to Word,
    process simulation, BPEL import/export and lots more. Good stuff.
  • ProActivity. This is another solution previously used on BizTalk projects. You can
    build your logical designs and export them to BizTalk (and vice versa). You’ve also got some simulation, analysis and reporting here.
  • Proforma. Here you can model in an MS Outlook-style environment. These cats also
    offer reference model specific to industries like supply-chain and financial services. You’ve also got BPMN, BPEL and UML support.

In my opinion, these solutions nicely fill in existing shortcomings in the current edition of BizTalk. Rule management is something I hear
about all the time, and now there are some legit solutions to make the BRE easier to commit to. If you don’t think the currently-offered
Orchestration Designer for Business Analysts (ODBA) is a full featured modeling tool (which probably no one does), then these
process modeling solutions are a great choice if you’re doing large scale modeling using BizTalk Server 2006. Very complimentary stuff.

I’m looking to get my hands on some of the software highlighted above, and if I’m successful, will write up reviews and highlights.

Technorati Tags: BizTalk