User Registration Process via asp.net

Nov 10, 2014 at 9:44 PM
Hi Folks -

I am trying to register authenticationGate Objects via asp.net code instead of cmdlets.

I have been hosting the powershell cmdlets in asp.net but this turned out to be a bit slow.
Now, I was trying to reflect the cmdlets and use the codeplex client to achieve this faster.

It looks like that the registration objects get created properly and associated with the users. When I’m starting the reset process it fails with the error about invalid number of tokens (see below).

The code snippet to set and hash the answers is below. Maybe you can give me some guidance what’s going wrong.

Anyone an idea what I'm doing wrong. Maybe the answers arent hashed correctly?
  //String gateData  = GetAnswers(person, answers);
            String gateData = BuildResponseData(answers, person.ObjectID.Value);
            RmGateRegistration rmResource = new RmGateRegistration();                                            
            rmResource.ObjectType = "GateRegistration";
            rmResource["GateID"].Value = "authenticationGateActivity3";
            rmResource["UserID"].Value = person.ObjectID;
            rmResource["WorkflowDefinition"].Value = workflowResource.ObjectID;
            rmResource["DisplayName"].Value = rmResource["GateID"].Value;
            rmResource["GateTypeId"].Value = "d1230ef0-c5fa-4473-be2a-30918b42ea2b";
            rmResource["GateData"].Value = gateData;                
            RmReference rmRef = client.Create(rmResource);




    public static String BuildResponseData(Dictionary<int, String> answers, String guid)
    {

        List<byte> response = new List<byte>();
        String responseStringEncoded = String.Empty;
        foreach (KeyValuePair<int, String> answer in answers)
        {
            response.AddRange(StringToByte(answer.Key.ToString()));
            response.AddRange(StringToByte("\n"));
            response.AddRange(sha256encrypt(Normalize(answer.Value) + guid));
            //response.AddRange(sha256encrypt(Encoding.Unicode.GetString(hashed) + guid));
            response.AddRange(StringToByte("\n"));
        }
        return Convert.ToBase64String(response.ToArray());
    }

Working at other clients:
<RequestParameter xmlns:q1="http://microsoft.com/wsdl/types/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CreateRequestParameter"><Target>ca009fce-5196-4c74-b328-c3b7b8f5e2c9</Target><Calculated>true</Calculated><PropertyName>GateData</PropertyName><Value xsi:type="xsd:base64Binary">AAAAAAAAAAAAAAAA</Value><Operation>Create</Operation></RequestParameter>

Not working in my DEV
<RequestParameter xmlns:q1="http://microsoft.com/wsdl/types/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CreateRequestParameter"><Target>38cbd9f5-2156-46d3-a8f3-d8c2b83b4a8d</Target><Calculated>false</Calculated><PropertyName>GateData</PropertyName><Value xsi:type="xsd:base64Binary">e8jHPlJQ3g90e6t+4ZeDlIXH+jbZw4+3y5tzKir7+hA=</Value><Operation>Create</Operation></RequestParameter>



The error page was displayed to the user.
Details:
Title: Error
Message: An error has occurred. Please try again, and if the problem persists, contact your help desk or system administrator. (Error 3000)
Source:
Attributes:
Details: System.ArgumentException: data contains an invalid number of tokens
at Microsoft.IdentityManagement.CredentialManagement.Portal.Gates.GateData..ctor(Byte[] data)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Gates.QAGateControl.Initialize(Mode mode, Byte[] data, Byte[] settings)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Components.DriverBase.GetCurrentGate()
at Microsoft.IdentityManagement.CredentialManagement.Portal.BasePage.ShowCurrentGate(Control container)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Reset.MoveToAuthenticationGates()
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
CorrelationId:
RequestId:
ErrorCode: 3000
CaughtTime: 11/10/2014 20:40:49

Web Portal: FIM Password Reset Portal
Session Id: w2o0qoue1sfqaczmdg55h4vm
IP Address: 10.0.1.4



Microsoft.IdentityManagement.CredentialManagement.Portal: System.Web.HttpUnhandledException: ScriptManager_AsyncPostBackError ---> System.ArgumentException: data contains an invalid number of tokens
at Microsoft.IdentityManagement.CredentialManagement.Portal.Gates.GateData..ctor(Byte[] data)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Gates.QAGateControl.Initialize(Mode mode, Byte[] data, Byte[] settings)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Components.DriverBase.GetCurrentGate()
at Microsoft.IdentityManagement.CredentialManagement.Portal.BasePage.ShowCurrentGate(Control container)
at Microsoft.IdentityManagement.CredentialManagement.Portal.Reset.MoveToAuthenticationGates()
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at Microsoft.IdentityManagement.CredentialManagement.Portal.Site.ScriptManager_AsyncPostBackError(Object sender, AsyncPostBackErrorEventArgs eventArgs)
at System.Web.UI.ScriptManager.OnAsyncPostBackError(AsyncPostBackErrorEventArgs e)
at System.Web.UI.PageRequestManager.OnPageError(Object sender, EventArgs e)
at System.Web.UI.TemplateControl.OnError(EventArgs e)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.default_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)