Enough of lists!  The last few posts, I’ve been dealing with the same old boring lists, and I’ve grown tired of that.  So today, I want to show a quick example of how to use some of the Users and Groups web services to handle user and group management.

So let’s say I have a brand new user.  They have astounding technical skills, so I decide that I want to add her to a special group of users that I’ll call “Super Users”.  The only issue, however, is that this group does not exist.  So to check all the items off my list and call it a day, I need to:

  • Create the “Super Users” group;
  • Add Maria to this group; and
  • Add some missing user information about Maria

The first thing we need is to create the new SharePoint group.  This is easy:

<cfsharepoint action="addgroup"
              domain="localhost"
              userName="un"
              password="pwd"
              name="theresult"
              wsdl="http://localhost/_vti_bin/UserGroup.asmx?wsdl"
              params="#{groupName="Super Users",
                        ownerIdentifier="mycomp\joel",
                        ownerType="user",
                        defaultUserLoginName="mycomp\joel",
                        description="A group of really cool, really powerful users :)"
                       }#"
/>

Regarding the info being passed, there’s nothing really to speak of.  However, you should notice that the method “addgroup” is not listed in the CF9 reference as being supported by the <cfsharepoint> tag (and believe me, a quick test reveals that they mean it!).  Fortunately, this isn’t a big deal.  While the method may not be directly supported by CF9, you can always pass the full path to the correct WSDL file with the “wsdl” attribute in the <cfsharepoint> tag and it will work just fine 🙂  (BTW, the correct WSDL file can be determined by looking at the MSDN reference for the web service method in question).

Ok, so we’ve created our group.  Now we need to add Maria.

<cfsharepoint action="addusertogroup"
              domain="localhost"
              userName="un"
              password="pwd"
              name="theresult"
              params="#{groupName="Super Users",
                        userName="Maria",
                        userLoginName="mycomp\Maria",
                        userEmail="marai@singularityconcepts.com",
                        userNotes="She's pretty funny!"
         }#"
/>

Again, super simple.  In the params, you simply pass the name of the group and some basic information about the person being added.

That’s about it, nothing to it.  However, let’s assume for the sake of this post dragging on just a bit longer that during the process of adding Maria to the Super Users group we made a mistake–let’s say we mispelled her e-mail address.  No problem, simply invoke the “UpdateUserInfo” and pass the right information:

<cfsharepoint action="updateuserinfo"
              domain="localhost"
              userName="un"
              password="pwd"
              name="theresult"
              wsdl="http://localhost/_vti_bin/UserGroup.asmx?wsdl"
              params="#{userName="Maria",
                        userLoginName="mycomp\Maria",
                        userEmail="maria@singularityconcepts.com",
                        userNotes="She's pretty funny!"
                       }#"
/>

As with the “AddGroup” method, the “UpdateUserInfo” is not currently supported by the <cfsharepoint> tag.  However, as before, accessing the method is as easy as passing the path to the WSDL file in the “wsdl” attribute.

So these examples have been pretty simple.  However, they continue to show how easy CF9 makes interacting with SharePoint–even unsupported methods are handled with great ease.  Yep, I’ve very happy 🙂