I'm getting this error:
"For the RSASSA-PKCS1-v1_5 signature method you must use the constructor which takes an additional AssymetricAlgorithm "key" parameter"
when I try to make a request with my IOAuthSession object.
I assume its referring to IOAuthSession constructor but IOAuthSession doesn't have a "key" parameter in the constructor.
Here's my code:
IOAuthSession consumerSession = new OAuthSession(consumerContext, requestTokenUrl, UserAuthoriseUrl, accessTokenUrl);
IConsumerRequest getOrganisationRequest = consumerSession
.Request()
.ForMethod("GET")
.ForUri(new Uri("https://api.xero.com/api.xro/2.0/Organisation"))
.SignWithToken(accessToken);
Any Help will be much appretiated.
I think that error message is wrong, there is no constructor overload that takes a key.
That said I believe what's wrong is you are failing to assign the key to the consumer context:
You should have something like this:
var consumerContext = new OAuthConsumerContext
{
ConsumerKey = "weitu.googlepages.com",
SignatureMethod = SignatureMethod.RsaSha1,
Key = certificate.PrivateKey // this is what you're missing
};
IOAuthSession consumerSession = new OAuthSession(consumerContext, requestTokenUrl, UserAuthoriseUrl, accessTokenUrl);
...
Let me know if that helps.
Related
I'm trying to use RelatedEntitiesQuery, Target and ColumnSet below which are a part of Retrieve Request, yet I'm met with the error
'RetrieveRequest does not contain a definition for RelatedEntitiesQuery'.
var request = new RetrieveRequest()
{
RelatedEntitiesQuery = OppCollection,
Target = new EntityReference("csp_installationsite", isGuid),
ColumnSet = new ColumnSet("Installation Site")
};
RetrieveResponse response = (RetrieveResponse)service.Execute(request);
I've also tried request.RelatedEntitiesQuery = OppCollection; and met with same error.
Any help greatly appreciated.
I have a need to manage Kerberos Resource Based Delegation in C# (I know it's easier in Powershell but that is not the requirement). The attribute on the user/computer/service accounts is msDS-AllowedToActOnBehalfOfOtherIdentity, but this seems to be some COM object which I can't seem to deal with in C#:
static void Main(string[] args)
{
string ou = #"OU=some,OU=ou,DC=corp,DC=com";
string cn = #"someaccount";
DirectoryEntry de = new DirectoryEntry();
de.Username = #"CORP\userwithOUrights";
de.Password = #"password";
de.AuthenticationType = AuthenticationTypes.Secure;
de.Path = $"LDAP://CN={cn},{ou}";
Object a = de.Properties["msDS-AllowedToActOnBehalfOfOtherIdentity"];
}
After this, a doesn't seem to be anything I can do much with, unlike other properties. It is some COM object and I need to get the accounts which are in there. Powershell reports that this property returns a System.DirectoryServices.ActiveDirectorySecurity object and I see useful methods in this class for decoding the binary format which is stored in AD etc. But this does not seem to be the return type from the property call in C#.
Update: All of this is now better documented in an article on my website: Handling NT Security Descriptor attributes
According to this the "attribute syntax" for that attribute is 2.5.5.15. According to this, that means it's a "String(NT-Sec-Desc)". According to this, that means it's a IADsSecurityDescriptor COM object.
You can add a COM reference in your project to "Active DS Type library" and cast it directly to IADsSecurityDescriptor, like this:
var act = (ActiveDs.IADsSecurityDescriptor)
de.Properties["msDS-AllowedToActOnBehalfOfOtherIdentity"].Value;
Console.WriteLine(act.Owner);
The Owner property gives you a DOMAIN\Username.
According to this random code I found, it seems you can also use the RawSecurityDescriptor class to interact with it. There is a constructor that takes a plain string, but you also can't seem to get the raw string from the attribute from DirectoryEntry.
But I did remember that sometimes DirectorySearcher will give you values in a different type than DirectoryEntry (doesn't make sense, but it's true). That appears to be true here. DirectorySearcher gives this attribute to you as a byte[], and RawSecurityDescriptor does have a constructor that takes a byte[].
So it seems you can do something like this:
string ou = #"OU=some,OU=ou,DC=corp,DC=com";
string cn = #"someaccount";
var search = new DirectorySearcher(new DirectoryEntry($"LDAP://{ou}"), $"(cn={cn})");
search.PropertiesToLoad.Add("msDS-AllowedToActOnBehalfOfOtherIdentity");
var result = search.FindOne();
var act = new RawSecurityDescriptor(
(byte[]) result.Properties["msDS-AllowedToActOnBehalfOfOtherIdentity"][0], 0);
Console.WriteLine(act.Owner);
//make changes to act.DiscretionaryAcl
byte[] descriptor_buffer = new byte[act.BinaryLength];
act.GetBinaryForm(descriptor_buffer, 0);
var de = result.GetDirectoryEntry();
de.Properties["msDS-AllowedToActOnBehalfOfOtherIdentity"].Value = descriptor_buffer;
de.CommitChanges();
In this, act.Owner is an account SID.
public ISearchResponse<object> GetById(string id) {
var uri = new Uri("<myendpoint>");
var settings = new ConnectionSettings(uri).DefaultIndex("useraction-*").PrettyJson().DisableDirectStreaming(); //or try _all
var client = new ElasticClient(settings);
var search = new SearchRequest<object>
{
Query = new TermQuery
{
Field = "field",
Value = "example"
}
};
var response = client.Search<object>(search);
return response;
}
I'm having trouble getting NEST to work. When I try to call the query defined above, I get the following error:
System.Exception: If you use a custom contract resolver be sure to subclass from ElasticResolver
at Nest.JsonExtensions.GetConnectionSettings(JsonSerializer serializer) in C:\Users\russ\source\elasticsearch-net-master\src\Nest\CommonAbstractions\Extensions\JsonExtensions.cs
I've searched the internet for mention of this and can't seem to find anything other than the source code. I've pretty much followed the documentation exactly so I don't know what to change.
Does anyone out there know what this error is trying to tell me? I feel like it's an error behind the scenes that I don't have control over.
I'm happy to answer additional questions if people need more info.
Thanks.
Also I don't know where that path is coming from in the exception because I have no user "russ"
I'm new to Octokit.Net.
and I want to create issue in my program...
So I coded like this.
var github = new GitHubClient(new ProductHeaderValue("Hello"));
var i = new NewIssue("asdf");
i.Body = "asdf";
var issue = github.Issue.Create("JoyLeeSoft", "test", i);
When I call Create function, function always throws NotFoundException.
And the error message just "Not Found"
But, the repository is avaiable. https://github.com/JoyLeeSoft/test
How can I solve this?
Creating an issue means being properly authenticated first (as in Tests/Authentication/BasicAuthenticatorTests.cs)
If not authenticated, the default response of GitHub can be "repository not found".
I'm using the C# Facebook library. With that i wanted to post something on my own wall, but i'm getting an error (as described in the title):
(OAuthException) (#803) Some of the aliases you requested do not
exist: access_token=438781769472xxxxxxxxxxxxxxxxxx
This is what i'm doing in code:
FacebookClient facebookClient = new FacebookClient(myAccessToken);
var args = new Dictionary<string, object>();
args["message"] = "Test message";
args["caption"] = "Caption";
args["description"] = "Description";
args["name"] = "Name";
args["picture"] = "";
args["link"] = "";
// Not sure which one to use, but both give same error
facebookClient.Post(appAccessToken+"/feed", args);
//facebookClient.Post(appAccessToken, args);
Anyone any idea what the problem might be and how i can solve this??
facebookClient.Post(appAccessToken+"/feed", args);
should change to
facebookClient.Post("<page_id>/feed", args);
You need add the page id to which you need to post
You don't need to add the appAccessToken parameter to the Post method parameter. Your post URL will be automatically appended with the myAccessToken value used when instantiating facebookClient. If you amend your call to be facebookClient.Post("/feed", args); it should work fine.