I am currently trying to develop a SCIM endpoint to be called from AAD. I pretty much understand the setup of SCIM and the idea behind it (I think). The problem is that I can't wrap my head around how to practically work with the Schemas. Should I make a model in C# that reflects the Schema that we end up using or should I try to do some clever logic that "looks up" the schema in the endpoint when a AAD for instance tries to create a user and then parse the JSON based on that or is there another approach that I am totally missing?
I am using a .NET Core Web API and have a Users controller so far as I do not really need anything else for now from AAD.
Any help with how to "use" these schemas in practice will be greatly appreciated!
This sample may be helpful - https://github.com/AzureAD/SCIMReferenceCode/blob/master/Microsoft.SystemForCrossDomainIdentityManagement/Schemas/Core2UserBase.cs
namespace Microsoft.SCIM
{
using System.Collections.Generic;
using System.Runtime.Serialization;
[DataContract]
public abstract class GroupBase : Resource
{
[DataMember(Name = AttributeNames.DisplayName)]
public virtual string DisplayName
{
get;
set;
}
[DataMember(Name = AttributeNames.Members, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<Member> Members
{
get;
set;
}
}
When configuring your app in AAD you will also be able to go into the app > provisioning > attribute mappings > show advanced options > and then specify which attributes are required
Related
I would like to write method validation processes which will be similar to data annontations presented in Web API.
In web api we can validate an object, for example:
public class Numbers
{
[NumberOne]
public string Number1 { get; set; }
[NumberTwo]
public string Number2 { get; set; }
}
and as long as we define the attributes NumberOneAttribute and NumberTwoAttribute its gonna be ok.
The difference is that web api has access to the GlobalConfiguration.Configuration.Filters which it seems like signalr doesn't.
Is there anyway to validate requests by attributes? or I need to follow the worst case, validate each input in the invoked method?
Thanks,
Ori.
In SignalR 2.2.x there is no native way of achieving this, but there is a project on GitHub that that adds a Validation Module in the SignalR pipeline.
Basically, in order to use it, you add a new module to the pipeline:
GlobalHost.HubPipeline.AddModule(new ValidationModule());
Then, you can use attributes like [Required] for the models' properties and then decorate the desired methods with the [Validate] attribute.
Note that this is a proof of contept project.
Best regards!
A long time ago when I first looked at OData response payloads to GET requests contained links to other entities or entity sets (e.g. an OrderHeader entity would contain a link to the order's OrderDetails). I believe the correct term for this is hypermedia.
Today I'm checking out OData again and have built a OData v4 service using ASP.Net Web API however no such hypermedia links are being returned in the payloads. Why is this? Is it because the payload is now JSON (whereas when I looked years ago it was XML)? Is there any way to include hypermedia links in the payload?
Here's what I've built. I have an entity called Proposition:
public class Proposition
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public ICollection<Event> Events { get; set; }
}
Notice that a Proposition has a collection of Events. I was hoping that when I requested a Proposition via the OData endpoint that I would get a link to the Events resource, but I don't:
I've found some information at OData JSON Format Version 4.0 Plus Errata 02#JSON Format Design that suggests adding $format=odata.metadata=full to the URL will return what I need:
The odata.metadata=full format parameter indicates that the service MUST include all control information explicitly in the payload
(odata.metadata=full)
but I've tried that and I'm not getting back any such metadata (screenshot this time from Postman):
Postman shows me that what got returned was odata.metadata.minimal:
Why is it ignoring my request for full metadata?
You should be able to add $format=application/json;odata.metadata=full to your querystring to achieve this via a GET request.
Aha, nailed it. I was specifying the URL wrongly. It needs to be ?$format=application/json;odata.metadata=full
Thanks to Stuart Preston for the help: https://twitter.com/StuartPreston/status/601107122550616064
I have been tasked with writing a web-service that will be used as an integration point between an ASP.NET MVC application and corporate SAP. Basically, I just have to write a SOAP web-service (Wcf SOAP) with an endpoint that SAP will call and transmit a bunch of data that I will then have to store in a SQL Server database.
I've never written a web-service before and am a but unsure on how the process will ultimately work. I generated an XML schema from the EF classes in the MVC application which I plan to provision SAP with for the data they are to send to the web-service. My solution designer suggested that I mimic the message structure that he uses in one of his REST web-services. This structure is as follows for the in-comming request:
public class DtoRequest<T> : IDtoRequest where T : class
{
public InteractionContext Context { get; set; }
public T Request { get; set; }
}
The InteractionContext is to hold various properties such details of the calling application and a license key for authentication. The Request will contain the payload.
namespace RfqService.Messages
{
public class SendRfqRequest : DtoRequest<RequestDataDto>
{
}
public class SendRfqResponse : DtoResponse<DtoVoidResponse>
{
}
}
The RequestDataDto looks as follows:
namespace RfqService.DataTransferObjects
{
[DataContract]
public class RequestDataDto
{
[DataMember]
public int RequestId { get; set; }
[DataMember]
public DateTime CreatedDate { get; set; }
[DataMember]
public DateTime DateProcessed { get; set; }
[DataMember]
public string Status { get; set; }
[DataMember]
public string XmlData { get; set; }
}
}
What I'm planning is for the XmlData in the RequestDataDto to contain the xml data sent from SAP that I can then deserialize into the EF classes and persist to the database.
SAP can then call an endpoint in my .asmx file:
[WebMethod]
public SendRfqResponse SendRfq(SendRfqRequest request)
{ ... }
Problem I'm facing is when inspecting the implementation of the the REST service of the solution designer. He calls the REST endpoint from a Webforms application. I can see how he constructs the message object in C# and send it to the web-service. I have no idea how this will work when its coming from a different platform like SAP. I've been trying to read up on SOAP in general and have come across the following extract here:
The primary difference between ORPC and the RPC protocols that preceded them was that ORPC codified the mapping of a communication endpoint to a language-level object.
Is the data sent from SAP automatically converted to my Request object? Does the data come in XML and I have to deserialize it into my object that in turn contains xml data in the payload? Are the parameters in the InteractionContext come from what's in the SOAP object's header? Do I have to serialize my response into xml before returning it to SAP?
Example If you are doing a REST web service call
If you really are doing a SOAP call.
Then load create a new client service using the wsdl from IIS where the service is hosted.
This will create a PROXY in ABAP.
You just call that proxy.
The data sent is transformed in XML as per the WSDL definition for you.
Equally on the IIS end the Service should populate the your Data Contract type for you automatically.
You should not have to worry about XML anywhere if done properly and you are using SOAP.
ABAP->IIS
if its aysnch call you will need to set up reliable messaging on the SAP side. That will keep you basis guy busy
In my solution there are total three projects. Two of them is web application in ASP.Net MVC and one is C# class library. Both web applications use same DB so I created C# class library and put ADO.Net Entity Data Model(EDMX) in it. I added reference of C# class libray project in web applications and using ADO.Net Entity Data Model to access database. This working properly, I am able to access table, add/edit/delete records but issue comes when I am trying to write data annotations for validation. Class generated by EDMX in C# class library project for table is like this:
namespace EDMXProjectNamespace
{
using System;
using System.Collections.Generic;
public partial class DrugClass
{
public DrugClass()
{
this.Drugs = new HashSet<Drug>();
}
public int ID { get; set; }
public string Name { get; set; }
public string NName { get; set; }
public virtual ICollection<Drug> Drugs { get; set; }
}
}
For connection I added connection string generated in my C# class library project's App.config to Web.config so it's working fine. Now only issue is where to write data annotations for validating user input.
Thanks in advance....
Thanks all for your valuable replies.
Finally I found solution for this problem. Instead of creating partial classes and add data annotations there, I created ViewModels for my views and added my data annotations there. With ViewModel I am able to validate my user's input.
I need to write a RESTful WCF service that maintains a dictionary (or any other suitable data structure) with userId:userData as key:value pairs.
For that I first need to implement an interface for getting and setting userData (the specific configuration is enclosed):
GetConfiguration() : returns default config when user hasn’t set a config yet
GetConfiguration(string id)
SetConfiguration(string id, Configuration configurationSchema)
Then I'll need to write a service that implements this interface.
As a newbie in WCF I'm not sure how to do it. I tried to look for relevant references but didn't found any.
Appreciate any help/relevant references, Thanks !
The userData object:
public class ConfigurationSchema
{
public string MobileNumber { get; set; }
public List<string> Habits { get; set; }
public ConfigurationSchema(string mobileNumber, List<string> habits)
{
this.MobileNumber = mobileNumber;
this.Habits = habits;
}
}
may be below video will help you to create a WCF service. Once create simple WCF service after that add your code.
https://www.youtube.com/watch?v=GzN1vHWlJjA
If you did not find references to help you, I'd suggest you learn to google before you tackle programming problems. It's worth it. For your problem:
Open Visual Studio
Chose WCF project
Replace example complex data structure by your own class
Rename methods
Rename interface
Press F5