I'm trying to connect to a kusto cluster I created in azure from Visual Studio 2019, .NET Core 3.1
I'm following this link:
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/connection-strings/kusto
This is what I'm doing:
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var accessToken = await azureServiceTokenProvider.GetAccessTokenAsync(clusterUri);
var managedIdentity = "<managed identity>";
var kustoConnectionStringBuilder = new KustoConnectionStringBuilder(clusterUri))
.WithAadManagedIdentity(managedIdentity);
But I keep getting this error:
"Exception Message: Tried the following 3 methods to get an access token, but none of them worked."
What am I doing wrong?
Is there a simple way to connect to the cluster?
Judging by the exception text, you are not getting it from Kusto SDK.
Can you debug to see what line in your code is throwing this error?
If you are using managed identities and the identity you need is available in your environment, you do not need the first two lines; all you need is the managed identity id.
Alternatively, if you wish to perform the auth yourself, you need to follow the "token provider" pattern and use the AzureServiceTokenProvider's GetAccessTokenAsync method:
Func<string> tokenProviderCallback; // User-defined method to retrieve the access token
// Recommended syntax
var kustoConnectionStringBuilder = new KustoConnectionStringBuilder(serviceUri)
.WithAadTokenProviderAuthentication(tokenProviderCallback);
Related
I'm trying to get items from SharePoint using the Graph API in the name of the user, all these done inside a .net core 3.1 web app using oauth. When I request for specific items in a SharePoint document library I get the following ServiceException:
ex = {"Code: itemNotFound\r\nMessage: The resource could not be found.\r\nInner error:\r\n\tAdditionalData:\r\n\trequest-id: 7605d475-5967-481e-a16c-ab1fad610ef9\r\n\tdate: 2020-04-15T21:27:48\r\nClientRequestId: 7605d475-5967-481e-a16c-ab1fad610ef9\r\n"}
My calling function is the following:
var searchResult = await graphServiceClient
.Sites[$"{SharePointSiteId}"]
.Drives[$"{SharePointDocumentLibraryId}"]
.Items[$"{InvoicesFolderId}"]
.Children
.Request()
.GetAsync();
where:
SharePointSiteId is a fully qualified SPS site Id
SharePointDocumentLibraryId id of the document library
InvoicesFolderId id of the folder in which I'd like to enumerate the children elements
The strange is that until I request for the Drive only:
var searchResult = await graphServiceClient
.Sites[$"{SharePointSiteId}"]
.Drives[$"{SharePointDocumentLibraryId}"]
.Request()
.GetAsync();
everything goes fine.
Strange thing 2: If I call the API using the Graph explorer with the same user in the same time using the Item identifier {InvoicesFolderId}, it gives back its children well.
Needless to say, the user can login to the SPS site and do whatever she wants. :)
I am able to reproduce the same exception thrown when calling from Graph .Net SDK in C#. Taking the exact same URL that is generated by SDK and testing in Graph Explorer is successful as well. I would recommend opening an issue on the Graph .Net SDK repo.
I would like to use IBM Watson Conversation service to build a chatbot web application in the Asp.Net platform. I installed IBM.WatsonDeveloperCloud Asp.Net package today, but have no idea what I should do with it and there is no document. There are about 50 projects in the solution, which one can be used for the so called simple chatbot web application?
Watson Developer Cloud has all the documentation that you need to use Watson Services, include Conversation Service.
Here are some examples to use Conversation:
Installation
Nuget
PM > Install-Package IBM.WatsonDeveloperCloud.Conversation.v1
Project.json
"dependencies": {
"IBM.WatsonDeveloperCloud.Conversation.v1": "1.2.0"
}
Usage
You complete these steps to implement your application: Configure a workspace. With the easy-to-use graphical environment, you set up the dialog flow and training data for your application. Develop your application. You code your application to connect to the Conversation workspace through API calls.
Instantiating and authenticating the service
Before you can send requests to the service it must be instantiated and credentials must be set.
// create a Conversation Service instance
ConversationService _conversation = new ConversationService();
// set the credentials
_conversation.SetCredential(<username>, <password>);
Send message:
// create message request
MessageRequest messageRequest0 = new MessageRequest()
{
Input = new InputData()
{
Text = <input-string0>
}
};
// send a message to the conversation instance
var result0 = _conversation.Message(<workspace-id>, messageRequest0);
// reference the message context to continue a conversation
messageRequest messageRequest1 = new MessageRequest()
{
Input = new InputData()
{
Text = <input-string1>
},
Context = result.Context
};
// Send another message including message context.
result1 = _conversation.Message(<workspace-id>, messageRequest1);
Obs.: In this link have one full guide step-by-step to use Watson Conversation Service with .Net.
See the Official Documentation for .Net SDK
One good Tutorial Video Guide to Integrating Watson Conversation in your Application.
See the Official API Reference for use Watson Conversation Service (You can have a base with this link).
With new firebase version, y need to access by node.js at my firebase application.
var firebase = require("firebase");
var parms={.......}
firebase.initializeApp(parms);
var token = firebase.auth().createCustomToken('123'); //Token generated successfully
//Line below throws error
firebase.auth().signInWithCustomToken(token).catch(function(error) {
//do something
});
If I use signInWithCustomToken from javascript in the browser, it works fine. But if I use it from command line: node file.js, it throws the error: firebase.auth().signInWithCustomToken(token) generate "Object has no method 'signInWithCustomToken'" error
Why?
On this part the web and node apis are different.
As stated in the Upgrade Guide (https://firebase.google.com/support/guides/firebase-web#update_your_authentication_code_numbered)
you need to use a service account for node.js apps. A good point to start is this page: https://firebase.google.com/docs/database/server/start#section-account
I would have loved to paste you the links to the auth api pages, but I'm only allowed to post 2 links. :)
I keep getting a 500 error when trying to create the ODataClient and passing in ODataSettings with new NetworkCredentials(username, password). Anyone have any examples of creating this service with Basic Authentication?
I enabled basic authentication for a sample OData Web site, and then I was able to access it using Simple.OData.Client and the following code:
var settings = new ODataClientSettings();
settings.UrlBase = "http://localhost/ProductService/odata";
settings.Credentials = new NetworkCredential("Tester", "tester123");
var client = new ODataClient(settings);
If it doesn't work for you I suggest you check if it works when you disable basic authentication and open the site for anonymous access. If it still doesn't work, then the problem is with something else. Otherwise let me know what platform and Simple.OData.Client version you are using (I tested on .NET 4.0, .NET 4.5 and Simple.OData.Client v.2.0.0).
In our company, we have a project which should use Novell eDirectory with .net applications.
I have tried Novell Api (http://www.novell.com/coolsolutions/feature/11204.html) to connect between .NET applications. It is working fine.
But, as per requirement, we specifically need .net API to connect not with Novell Api, which is not working. Connection and binding with .NET Api DirectoryServices not working.
Our Novell eDirectory is installed with following credentials:
IP address: 10.0.x.xx(witsxxx.companyname.com)
Tree : SXXXX
New Tree Context: WIxxxK01-NDS.OU=STATE.O=ORG
ADMIN Context is: ou=STATE,o=ORG
admin : admin
password: admin
I used Novell Api and used following code
String ldapHost ="10.0.x.xx";
String loginDN = "cn=admin,cn=WIxxxK01-NDS,OU=STATE,o=ORG";
String password = string.Empty;
String searchBase = "o=ORG";
String searchFilter = "(objectclass=*)";
Novell.Directory.Ldap.LdapConnection lc = new Novell.Directory.Ldap.LdapConnection();
try
{
// connect to the server
lc.Connect(ldapHost, LdapPort);
// bind to the server
lc.Bind(LdapVersion, loginDN, password);
}
This is binding correctly and searching can be done.
Now my issue is with when I trying to use .NET APi and to use System.DirectoryServices
or System.DirectoryServices.Protocols, it is not connecting or binding.
I can't even test the following DirectoryEntry.Exists method. It is going to exception.
string myADSPath = "LDAP://10.0.x.xx:636/OU=STATE,O=ORG";
// Determine whether the given path is correct for the DirectoryEntry.
if (DirectoryEntry.Exists(myADSPath))
{
Console.WriteLine("The path {0} is valid",myADSPath);
}
else
{
Console.WriteLine("The path {0} is invalid",myADSPath);
}
It is saying Server is not operational or Local error occurred etc. I don't know what is happening with directory path.
I tried
DirectoryEntry de = new DirectoryEntry("LDAP://10.0.x.xx:636/O=ORG,DC=witsxxx,DC=companyname,DC=com", "cn=admin,cn=WIxxxK01-NDS,o=ORG", "admin");
DirectorySearcher ds = new DirectorySearcher(de, "&(objectClass=user)");
var test = ds.FindAll();
All are going to exceptions.
Could you please help me to solve this? How should be the userDN for DirectoryEntry?
I used System.DirectoryServices.Protocols.LdapConnection too with LdapDirectoryIdentifier and System.Net.NetworkCredential but no result. Only same exceptions.
I appreciate your valuable time and help.
Thanks,
Binu
To diagnose your LDAP connection error, get access to the eDirectory server from the admins, and use iMonitor (serverIP:8028/nds and select Dstrace), in Dstrace clear all tabs and enable LDAP tracing, then do your bind see what happens on the LDAP side to see if there is a more descriptive error there. Or if you even get far enough to bind and make a connection.