Skip to main content

Blog

Go Search
Blog
ViaEcole.se
  

CreateMemberWithPropertiesEx

This article applies to Microsoft Live@edu program and using e-mail with Outlook Live or Hotmail.

There are many ways to create Live users with Live@edu. The easiest way is to use WLAC (Windows Live Admin Center), which you can access at https://domains.live.com. Another way is to use Powershell:

New-Mailbox -Name "AStudent" -FirstName Able -LastName Student -DisplayName "A Student" -WindowsLiveID astudent@mydomain.edu -Password (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force) -MailboxPlan GalDisabledMailboxPlan

(For information how to connect to Live@edu with Powershell, see http://help.outlook.com)

For bulk creating you can either upload a file to WLCA or use Powershell and CSVparser. For more information about Powershell and CSVparser, read this article by Jonny Chambers: http://liveatedu.spaces.live.com/blog/cns!C76EAE4D4A509FBD!798.entry

One thing all these methods have in common is that they force the user to add additional information when accessing the account, e.g. secret question, region and event the password.

By setting these parameters when creating the account, the request will be limited to an acceptance of the user agreements:

Instead of using Powershell and CSVParser, you can use the APIs for account provisioning. There is a method which creates a new member in a domain with additional credentials and properties, CreateMemberWithPropertiesEx: http://msdn.microsoft.com/en-us/library/bb963920.aspx

Calling this method requires Microsoft approval. Contact us at dsupport@microsoft.com if you are a partner and want to apply for permission.

Send an e-mail to dsupport@microsoft.com and ask them to grant access to the restricted method CreateMemeberWithPropertiesEx.

Download the Command Line application. The Command Line application is also a part of the SDK and can be downloaded here:  http://go.microsoft.com/fwlink/?LinkID=86932&clcid=0x409. Open the solution for CommandLineAdv.


The CommandLineAdv does not contain a method for CreateMemberWithPropertiesEx, so you need to add it to ManageDomain2.cs. Add this piece of code right after the method CreateMemberWithProperties.

Next step is to make sure Class1.cs can handle the new method. Add the following piece of code, preferable after if (addMember):

For this example I have added code for all parameters in the method, but you can naturally add them as input parameters to the console application.

Next step is to make the console application recognize a new command. For creating a new user you enter –a, as in add member. Suitable for this example could be –ax, for add extended member. First you need to declare a Boolean which tells the application to create an extended member. In Class1.cs, where the members are declared, add

bool addMemberEx = false;

 

Where the input parameters are checked, add:

else if (args[i] == "-ax")

    addMemberEx = true;

 

Last step is to test the application. Compile it and go to a command prompt. Enter for instance:

CommandLine.exe –au:admin@mydomain.edu –ap:MyPassword –ax –m:newuser –p:NewUserPassword –d:mydomain.edu –fcp:0

You will see the response:

Signing admin into the service… Admin signed into the service.

Adding extended member newuser@mydomain.edu... Extended Member added.

The user is now created with extended parameters and will be sent directly to the inbox when logging on the first time. When accessing SkyDrive or other Live services all that is needed is an acceptance of user agreements.

Renaming an uploaded document

Paul Gavin describes a way to rename uploaded documents in a SharePoint library (http://paulgalvin.spaces.live.com/Blog/cns!1CC1EDB3DAA9B8AA!655.entry). One of the problems this solution may generate is when you have added extra columns to the document library. SharePoint handles documents in two steps. First it uploads the document (Upload.aspx) and then it adds the extra properties (EditForm.aspx). When uploading a document you will get redirected to EditForm.aspx only if there have been columns added to the document library. Since changing name of a file is an asynchronous process, this may occur after you have been redirected to EditForm.aspx, which will cause an annoying error message when saving the properties:

The easiest way to get around this is to instruct the users not save the properties by clicking cancel. A more user friendly way is to stop EditForm.aspx from showing up and redirect the users back to the document library. This article describes the latter case and builds on Paul Gavin's solution.

First of all, create a custom folder with a unique EditForm.aspx. It is recommended to have a separate list definition, especially when combining with other features. Create a code file named EditForm.cs and add it to a separate folder.

Note that the event receiver needed for changing name of the uploaded file has been omitted.

Open the EditForm.aspx-page, add the current assembly and modify the Page attributes according to the figure below.

<%@ Assembly Name="ViaEcole.MyCustomFolder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9750e819ae02b811" %>

<%@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="ViaEcole.MyCustomFolder.EditForm" %>

 

Open the EditForm.cs and add code to override the OnLoad-method. The trick is to have a hidden property in the list definition and have the event receiver to set it after the name has been changed. The OnLoad-method checks if the property has been set. If not, the user will be redirected to the document library.

Add a hidden field to the list definition.

<Field ID="{A3C4D5B0-E245-43f2-95D6-F3CD683224F7}" Type="Boolean" Group="_Hidden" Name="SetPermission" DisplaceOnUpgrade="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="SetPermission" DisplayName="VESetPermission" XName="{FBF29B2D-CAE5-49aa-8E0A-29955B540122}" Filterable="TRUE" Sortable="TRUE" Sealed="TRUE" Hidden="TRUE" FromBaseType="TRUE" ReadOnly="TRUE" />

 

Remember to add code to set the property PERMISSION_HAS_BEEN_SET_FIELD in the event receiver.

item[PERMISSION_HAS_BEEN_SET_FIELD] = true;

Note, this will not solve the problem when uploading a document directly from Word.

 ‭(Hidden)‬ Admin Links