I am a total newbie with dynamics crm online (2011), and although I have been working through the SDK sample code, I am trying to find the simplest way to perform a basic authenticated connection to our online Dynamics CRM service, and push some very basic data to a custom entity/extension I have created.
Hopefully you can see from the above code snippet (sensitive data blurred), I am probably trying to circumvent the authentication process? The above code example was based a little on some of the code samples in the CRM SDK, and also from a code project example. I don't know if the code above would even work? actually it seems to try, and only when the "serviceProxy.Create" is executed do I get an authentication error.
I have also managed to navigate out of the corporate firewall with the following addition to my app.config file:
<system.net>
<defaultProxy useDefaultCredentials=”true”>
<proxy usesystemdefault="true"/>
</defaultProxy>
</system.net>
Again, not sure if there is a very basic way to connect? or should I really fall back to the SDK helper files?
This is the simplest way to connect to CRM Online, you need only to add reference to Microsoft.Xrm.Sdk.Client and Microsoft.Xrm.Client.Services
CrmConnection crmConnection = CrmConnection.Parse("Url=https://XXX.crm.dynamics.com; Username=user#domain.onmicrosoft.com; Password=passwordhere;");
OrganizationService service = new OrganizationService(crmConnection);
Entity account = new Entity("account");
account ["name"] = "Test Account";
Guid accountId = service.Create(account);
Refers to this msdn article for create the right connection string
Simplified Connection to Microsoft Dynamics CRM
Related
I'm trying to connect to the Google Datastore on my account with service account credentials file (which I've created according to the documentation), but I'm encountering with authentication error while trying to insert an entity:
Grpc.Core.RpcException: Status(StatusCode=Unauthenticated,
Detail="Exception occured in metadata credentials plugin.")
My code is:
var db = DatastoreDb.Create("myprojectid");
Entity entity = new Entity{
Key = db.CreateKeyFactory("mykindname").CreateIncompleteKey()
};
var keys = await db.InsertAsync(new[] { entity });
The GOOGLE_APPLICATION_CREDENTIALS variable refers to the credentials file and when calling GoogleCredential.GetApplicationDefaultAsync() to see if the credentials object is valid it indeed looks good...
I saw some earlier examples which used the GetApplicationDefaultAsync function togehether with some DatastoreService object - but I couldn't find the DatastoreService object (probably it was there in old versions...) in the latest .Net API: Google.Cloud.Datastore.V1
Notice that I don't want to use the other authenticaiton methods:
1) Using the gcloud cli.
2) Running from Google environment (app engine for example).
Any idea how to solve this?
After the great help of Jon Skeet the issue was solved.
The authentication issues can occur if you don't reference all the required Datastore dlls. Make sure that all the dlls are referenced on the project that are running the calls to the Datastore.
I've added the Google Datastore lib via the NuGet to my test project and everything worked!
Notice that in such cases it is recommended to enable gRPC logging. `(For exmaple: GrpcEnvironment.SetLogger(new ConsoleLogger()), there you'll probably see if there were issues loading several dlls...
Authentication can be broken if your system clock is significantly incorrect. Check your system time, and fix it if necessary, then try authenticating against Datastore again.
I maintain an ASP.NET Web API project which supports a simple REST end point for clients to post XML data to our server. This site is setup to support BasicAuthentication and works very well. All of our security checks are done at the network firewall and on the machine itself using custom Windows User accounts. Recently, one of our clients requires that we support a SOAP end point to receive the XML data as well.
My thought was to simply add a new WebService (Blah.svc) with supporting interface having the required [ServiceContract] and [OperationContract] attributes to my interface. I had hoped that I could simply expose the URL to our client and it would "just work". I am able to hit the end point, but this service is not able to extract the user name.
Here is my sample code:
public string CreateWorkItem(string xml)
{
var userName = HttpContext.Current.User.Identity.Name;
if (string.IsNullOrEmpty(userName))
userName = "NO USER NAME";
var elem = XElement.Parse(xml);
return $"Hello [{userName}]! You sent [{elem.Value}].";
}
Here are my results:
I've scoured the web to try and find out how to get access to the BasicAuthentication details in a Soap message, but I'm not having any luck. All the examples that I'm finding require that I create a new WCF project and expose it with a lot of web.config settings, or the examples are ~5 years old using older techniques.
I'd like this service to simply publish with my WebAPI project using the Publish... option inside Visual Studio. Unfortunately, I've not found a common denominator to make it work. I'm sure I'm missing something, and I hope someone can help.
Any help would be greatly appreciated!
Check this link out: WCF Services and ASP.NET
In short you need to enable ASP.NET Compatibility in your WCF service.
However, you may want to look into using OperationContext.Current.ServiceSecurityContext.*
The fact that it is HttpContext.Current.User.Identity.Name is returning null means either:
User is null; or
User is Anonymous
I have a few ideas to help resolve the issue.
1. Your User.Name is actually null
You might want to debug by grabbing HttpContext.Current.User and see if it's correct.
2. Go direct: get the cookie via a parameter
Try and pass the HttpContext as a parameter so you can grab the cookie?
public string CreateWorkItem(HttpContext context, string xml)
{
var username = context.Current.User.Identity.Name;
...
}
3. Your configurations are not setup properly
The alternative is that maybe your web.config or Global.asax is not setup to properly.
I have a requirement for getting a CRM URL via a custom workflow to use in the next step which is to send an email. The reason for this is to differentiate to users which server this email has come from (UAT/Live).
I have been trying to use HTTPContext route as advised from this site https://social.microsoft.com/Forums/en-US/31ff567d-65ea-4385-a764-68a2121ae8c0/ms-crm-2011-get-path-of-crm-server-url-in-plugin?forum=crmdevelopment but the result I get back is useless as I am I am only receiving an "/" back.
Does anyone know what to do from this point or why this may not be working?
This can't be accomplished, in a supported manner, without creating a connection to the CRM Discovery Service, which requires that you supply credentials. The organization service, available in the workflow does not have a method for discovering the organization's URL.
You have two options:
1) Pass it to the workflow as a parameter using the InputParameter code attribute on your CodeActivity.
2) Create (if you don't already have one) a configuration entity to store the URL and retrieve it in your code.
If you don't really need the URL (i.e., you are not creating a link) then you could just query the Organization entity for the Name attribute. That will give you the Organization's name - which would be the only unique part of the URL. This would allow you to indicate to the user if the Email was coming from UAT or Prod.
I ended up coming up with a solution by using the environment.machinename to pull through the server name. From there i could determine which production server the workflow had been run through and passed a string containing, dev, uat or live to the output to use in my activity emails.
Be aware i had to register the workflow without it being in sandbox mode. Hope this helps somebody in the future.
This was an extremely old question but I came across it while attempting to do something similar.
I found that there is a RetrieveCurrentOrganizationRequest request which was introduced in v9. This will work in sandboxed plugins.
You can use this to retrieve the endpoint urls like so
var currentOrg = base.OrgService.Execute(
new RetrieveCurrentOrganizationRequest()
) as RetrieveCurrentOrganizationResponse;
var url = currentOrg.Detail.Endpoints
.Where(e => e.Key == EndpointType.WebApplication)
.FirstOrDefault()
.Value;
More information here: RetrieveCurrentOrganizationRequest
When I used it, I found that there are 3 available URLs in the Endpoints collection:
Web Application
Organization Data Service
Organization Service
Relevant to CRM 2013 (which the OP was using at the time), there is also the RetrieveOrganizationRequest class which does the same as above; however you have to specify the Organization (and some other information)
I want to connect to microsoft dynamics CRM via tools or code, but every time I try I get this error :
the provided uri did not return any service endpoints
Also when I go to its discovery.svc link I get the following error :
An error has occurred.
Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
I check the IIS binding and its just bind to 5555 for HTTP and 5556 for HTTPS and also the above error occur on server side too, I mean when I go to http://myAddress:5555/XRMServices/2011/Discovery.svc both in server and clients I get the error. I cant find any thing that could solve my problem in the internet and I'm stock in this simple problem for several days.
I think after I solved my problem this could be useful for somebody. There was two problem first my server has configuration problem and server needs restart to free its memory. so it's not bad if you check how memory you are using, and if its possible restart the server.
and after that I have a proxy problem that could be fix with creating a file name app.config and writing this lines:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy >
</defaultProxy>
</system.net>
</configuration>
Then it'll works fine
I would like to create a C# application (.net 2.0 due to the API) to post new bookmarks to Delicious. I found a library: http://netlicious.sourceforge.net/ but I can't find any sample files. I added the DLL to my references and enter the following code:
Delicious.Connection.Username = "e-mail";
Delicious.Connection.Password = "password";
Delicious.Post.Add (url, description, extended, tags, date, replace, shared);
But i get an exception at the POST method: "The server is not responding. ServiceUnavailable"
What's the problem? I can use Delicious from firefox.
Are you using a Yahoo email address? The developer says :
Netlicious will continue working for users who have a del.icio.us
account. But, users will not be able to login with a Yahoo account.