Getting an error with Connect-NsxServer with powershell PowerNSX module - powershell

after running this command
$cred = get-credential
Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred
I get this error
Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Response Body:
At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1174\PowerNSX.psm1:4939 char:13
+ Throw "Connection to NSX server $NsxServer failed : $_"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Connection to N...Response Body: :String) [], RuntimeException
+ FullyQualifiedErrorId : Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Respons
e Body:
I see this in the error, but have never set this before either
The variable '$defaultNSXConnection' cannot be retrieved because it has not been set.
The PowerNSX module comment says:
Invoke-NsxWebRequest uses either a specified connection object as returned
by Connect-NsxServer, or the $DefaultNsxConnection global variable if
defined to construct a REST api call to the NSX API.
My account permissions can't be the issue. I can log into the NSX gui and have enterprise admin creds. I can also successfully log into Vsphere with powercli module and run cmdlets against it. It's specifically when I try to connect to NSX that I get an error. Lost at this point. Not sure why it won't work. Tried by IP and FQDN. the -vcenterserver parameter is prefered according to their documenation, and I do see Green text response directing to the correct nsx manager IP address. Everything looks right, but clearly something isn't.

powernsx apparently REQUIRES you to use the administrator#vsphere.local account to use it, regardless if your other admin account can make any API call supported by NSX with native API calls.
Didn't see that in the powernsx documentation. If it's not just an oversite on my part, that really should be front and center in their docs.

We have MS AD authenticated accounts that we use with vSphere. I use PowerNSX with my own credential and no, I do not have to use administrator#vsphere.local. The only way I have success is if I am careful to put the domain of the account in all-caps, Kerberos style. When I give the credential, the ONLY format that works for me is "username#MY.DOMAIN.COM" it is extremely case sensitive.
vSphere 6.7, NSX 6.4.8, PowerNSX 3.0.1174

Related

Error in check_twitter_oauth() : OAuth authentication error :

I am working to establish the connection with twitter using R. Need help to resolve this error:
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()
The code is:
library(twitteR)
library(ROAuth)
customer_key <- "XXXX"
customer_secret <- "XXXX"
access_token <- "XXXX"
access_secret <- "XXXX"
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
I also referred to similar answers, but couldn't resolve this error. I have tried the following :
used a library(base64enc)
Checked the firewall issue, have allowed the R application in Windows defender firewall settings using command prompt -
netsh advfirewall firewall add rule name="app name" dir=in action=allow program="Full path of .exe" enable=yes
Uninstalled R and have installed the latest version.
Have tried replacing (library(twitteR) and library(ROAuth)) with (library(openssl) and library(httpuv)).
Have tried using all the 4 libraries (twitteR, ROAuth, openssl, httpuv) as well.
Change this:
library(twitteR)
library(ROAuth)
to:
library("openssl")
library("httpuv")

"Access is denied due to invalid credentials" REST API error. How to solve?

I followed the documentation here: and here: Trying to integrate to a Personality Insights service via Android Java.
However, after the app runs, and using the correct username and password as mentioned in the guide... (the guide is not clear (2nd bullet point in "Before you begin") on which set of credentials to use - It says get the "service credentials" and credentials from the new service created - I tried with both and both fail with the same error below.)
Error:
12-11 01:49:56.201 29584-29632/? I/CredentialUtils: JNDI string lookups is not available. 12-11 01:49:56.269 29584-29632/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default 12-11 01:49:56.723 29584-29632/? D/OkHttp: --> POST https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 http/1.1 (1297-byte body) 12-11 01:49:56.803 29584-29632/? D/OkHttp: <-- 401 Not Authorized https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 (78ms, unknown-length body) 12-11 01:49:56.863 29584-29632/? E/WatsonService: POST https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13, status: 401, error: Not Authorized 12-11 01:49:56.865 29584-29632/? E/ERROR: Unauthorized: Access is denied due to invalid credentials
com.ibm.watson.developer_cloud.service.exception.UnauthorizedException: Unauthorized: Access is denied due to invalid credentials at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:492) at com.ibm.watson.developer_cloud.service.WatsonService$2.execute(WatsonService.java:254) at com.upen.personalityapp.MainActivity$RetrieveFeedTask.doInBackground(MainActivity.java:105) at com.upen.personalityapp.MainActivity$RetrieveFeedTask.doInBackground(MainActivity.java:87) at android.os.AsyncTask$2.call(AsyncTask.java:306) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:244) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 12-11 01:49:56.866 29584-29584/?
This is the code I am using; I am trying to pass a "text" input to the service.
service = new PersonalityInsights("2017-10-13");
service.setUsernameAndPassword("{myUsername}", "{myPassword}");
Profile profile = service.getProfile(text).execute();
System.out.println(profile);
return profile.toString();
I am using the com.ibm.watson.developer_cloud:personality-insights:3.8.0 dependency.
I tried connecting to the URL in the error (https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 ) via a browser. It prompts for a username/password combo. I entered my details from my IBM Cloud Lite service but it throws the HTTP Error 405. Is this how it's supposed to work on the browser?
For someone in the future;
Instead of service.setUsernameAndPassword(username, password);, I tried service.setUsernameAndPassword("username", "password"); and it worked.

How do I connect to a Windows-secured Service Fabric cluster from a computer outside the domain?

I have an on-premises Service Fabric cluster with security configured as follows:
"security": {
"ServerCredentialType": "Windows",
"WindowsIdentities": {
"ClustergMSAIdentity": "ServiceFabric#mydomain.com",
"ClusterSPN": "ServiceFabric/ServiceFabric.mydomain.com",
"ClientIdentities": [
{
"Identity": "mydomain\\admin1",
"IsAdmin": true
}
]
}
},
I have verified that
I can successfully connect to this cluster using Connect-ServiceFabricCluster from the same machine the cluster is running on
I can successfully connect to the Service Fabric Explorer from a machine outside the domain (the browser correctly prompts me for my Windows credentials)
If I remove "ServerCredentialType": "Windows", and rebuild the cluster, I am able to successfully connect from a machine outside the domain
However, I can't figure out how to Connect-ServiceFabricCluster using Windows authentication from outside the domain. I've tried
Connect-ServiceFabricCluster -ConnectionEndpoint 'cluster.mydomain.com:19000' -WindowsCredential
but that results in
WARNING: Failed to contact Naming Service. Attempting to contact Failover Manager Service...
WARNING: Failed to contact Failover Manager Service, Attempting to contact FMM...
False
Connect-ServiceFabricCluster : Could not ping any of the provided Service Fabric gateway endpoints.
At line:1 char:1
+ Connect-ServiceFabricCluster -ConnectionEndpoint 'cluster.mydomain.c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricTransientException
+ FullyQualifiedErrorId : TestClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster
I am never prompted to enter my credentials. Is there a way to pass my Windows credentials into Connect-ServiceFabricCluster? I was unable to locate this in the documentation for connecting securely.
Please try
WindowsCredential = $True
More info here https://learn.microsoft.com/en-us/powershell/module/servicefabric/connect-servicefabriccluster?view=azureservicefabricps

Java MongoDB Client: authentication failed when access to a server not configured to use an authentication

I have configured Java MongoDB Client to use MongoCredential.
Unfortunately when I access to a server that does not configured to use an authentication I get authentication failed exception:
Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server …. The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }
I do expect this exception when a server is configured to use an authentication and when Java MongoDB Client but not in this case.
Is it possible to configure Java MongoDB Client not to fail when access to a server not configured to use an authentication?
I am afraid not, your client does not know whether the server has auth enabed or not.
Your client connection code should match the auth parameters from the server, otherwise it fails.
What I did in this case, was to create a connection function which accepts auth credentials, when credentials are passed, used them - create the connection with auth credentials, otherwise no - create the connection with no auth credentials.
In this case, you should know what server has auth enabled

PHP SoapCLient, Soap call giving an error in Drupal

I am getting the following error, when I try making a SOAP call.
Warning: SoapClient::__doRequest() [soapclient.--dorequest]: php_network_getaddresses: getaddrinfo failed: Name or service not known in
and the error
HTTP-Could not connect to host
Things that I have ensured :
allow_url_fopen : is enabled.
The WSDL is being accessed. The server is not down.
I have set the SOAP time out to 15 seconds.
The IP of the host you are connecting to cannot be resolved. See my answer in
simplexml_load_file not working "php_network_getaddresses: failed: Name or service not known"
for what to do.