How to generate source files from navision webservice with ntlm authentication - wsimport

I am trying to generate the source files from a Navision web service(NTLM authentication) using wsimport.Below is the command
wsimport -XdisableSSLHostnameVerification -d generated -s source -Xauthfile auth2.txt -keep "https://XXX.XXX.XXX.XXX:XXXX/XXXell/WS/XXXXLimited/Page/XXXXXOrder"
in auth.txt
http[s]://user:password#host:port//
I am unable to generate the source files.Please help with any link or sample which can help
Any quick help will be appriciated....

just ask the Navision Admin to change the config to use Basic Auth:
How to: Use an Access Key for SOAP and OData Web Service Authentication
Cheers

This thread is pretty old but in case someone pass by I share my experience.
For NTLM you do not need file auth.txt
TL;TR
Use tools.jar com.sun.tools.internal.ws.WsImport and add Java options "-Dhttp.auth.ntlm.domain=MYDOMAIN" "-Djdk.http.ntlm.transparentAuth=allHosts" before if you use Java greater than 1.8.0_181.
Long version
Until Java 1.8.0_181, NTLM was enabled by default but it's not the case anymore (current version I use is 1.8.0_222"). See https://stackoverflow.com/a/54628051/349228
To be able to use NTLM with wsimport tool I had to use the tools.jar manually :
java "-Dhttp.auth.ntlm.domain=MYDOMAIN" "-Djdk.http.ntlm.transparentAuth=allHosts" -cp %JAVA_HOME%\lib\tools.jar com.sun.tools.internal.ws.WsImport -p "my.target.package.name" -d . -keep -encoding UTF-8 "http://navisionhost:7047/DynamicsNAV110/WS/Test 01/Page/MyPage"
Key part for NTLM is the 2 java options "-Dhttp.auth.ntlm.domain=MYDOMAIN" "-Djdk.http.ntlm.transparentAuth=allHosts". The rest is close to the native tool call except we run the Main Java Class from this jar %JAVA_HOME%\lib\tools.jar manually.

Related

How does one set a proxy in lazybones?

I'm behind a firewall and lazybones can't reach its repository without a proxy.
I've searched the source and can't seem to find any reference to a proxy that seems to be relevant.
Support was officially added in version 0.8.1 of Lazybones, albeit via a general mechanism to add arbitrary system properties to the application in its configuration file, ~/.lazybones/config.groovy.
You can read about the details in the project README, but in essence, simply add the following to your config.groovy file:
systemProp {
http {
proxyHost = "localhost"
proxyPort = 8181
}
https {
proxyHost = "localhost"
proxyPort = 8181
}
}
You can use the systemProp. prefix to add any system properties to Lazybones, similar to the way it works in Gradle.
Is that what You're looking for? Basically You need to add some properties to gradle.properties file.
I am using Cygwin on Windows and I have modified the last line of
~/.gvm/lazybones/current/bin/lazybones
to say
exec "$JAVACMD" "${JVM_OPTS[#]}" -classpath "$CLASSPATH" "-Dhttp.proxyHost=127.0.0.1" "-Dhttp.proxyPort=8888" "-Dhttp.nonProxyHosts=localhost|127.0.0.1" uk.co.cacoethes.lazybones.LazybonesMain "$#"
Please note the quotes around the options. It works very well with my local Fiddler installation.
I have found no better way to enable proxy support due to the way the script is using eval. Maybe a more experienced shell script programmer can come up with a more elegant solution.
I was able to get out through the proxy setting the environment settings of
Picked up JAVA_TOOL_OPTIONS: -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8080
-Dhttp.nonProxyHosts="lmig.com" -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8080
unfortunately my environment requires authentication so I couldn't provide the complete proxy this way. I first ran "OWASP Zed Attach Proxy (ZAP)" which allowed me to run a proxy on my own machine (at port 8080) which then provided the complete authentication required.
This was able to then run the complete "lazybones list" command which retrieved the contents of the respositories.
Unfortunately I was not able to create an application from those templates becuase bintray required a login (though an anonymous login would do) and couldn't seem to get an additional level of authentication (I received "Unauthorized" from bintray)

Open a file directly from a GitLab private repository

I have a private repository on a GitLab server and using the SSH I can pull a project using git clone.
But I want to run a script on linux command line directly from the server (more specific, a Drupal / Drush .make file)
I tried to run it using the raw file:
drush make http://server.com/user/project/raw/master/file.make
(for the convenience of non Drupal users let’s say)
curl http://server.com/user/project/raw/master/file.make
Without success. Of course, it returns me the login page.
Is it possible?
With Chris's valuable help, here is how you can run a script (drupal .make file in my case) from a GitLab server. (Probably it works for GitHub but I didn't test it. Maybe the syntax will be a bit different). (Of course this works for any type of script)
It can be done using the authentication tokens. Here is the documentation of the GitLab's API and here is the GitHub's API
For convenient I will use the https://gitlab.com as the example server.
Go to https://gitlab.com/profile/account and find your "Private token"
Then print the list of the projects and find the id of your project you are looking for
curl https://gitlab.com/api/v3/projects?private_token=<your_private_token>
or go there with your browser (a json viewer will help a lot)
Then print the list of the files that are on this project and find the id of your file you are looking for
curl https://gitlab.com/api/v3/projects/<project_id>/repository/tree?private_token=<your_private_token>
Finally get / run the file!
curl https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token>
In case you want to run the script (drupal .make)
drush make https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token> <drupal_folder>
(If you are here looking for a workflow to integrate GitLab with Aegir .make platforms without using tokens (maybe SSH?) please make a thread and paste here the link.)
EDIT
You can get the file without the project_id by using the encoded project name. For example the my-user-name/my-project will become: my-user-name%2Fmy-project
Update 2018-12-25:
as long as you're not downloading huge files, this should work:
curl -s -H "Private-Token: <token>" "https://gitlab.com/api/v4/projects/<urlencode("gitlab_username/project_name")>/repository/files/<path/to/file>/raw?ref=<branch_name>"
, a real example, downloading the file /README.md from the private repository https://gitlab.com/divinity76/Yur17, where the web download url is https://gitlab.com/divinity76/Yur17/raw/master/README.md?inline=false, is:
curl -s -H "Private-Token: afF2s1xgk6xcwXHy3J4C" "https://gitlab.com/api/v4/projects/divinity76%2Fyur17/repository/files/README%2Emd/raw?ref=master"
take special note of how the gitlab_username/repo_name was url-encoded, eg / became %2F (you can check how your username & repo name is as url-encoded by opening your browser javascript terminal and write encodeURIComponent("your_username/repo_name"); in the terminal and press enter.)
thanks to Jonathan Hall # gitlab at mg.gitlab.com, and https://docs.gitlab.com/ee/api/repository_files.html , and tvl for helping reach a solution.
Update 2018-12-11: this method no longer works, now it just serves the login page, with a message saying need to log in to continue, even using HTTP 200 OK (shame on them), will update if i find out why ( #XavierStuvw claims it's security concerns related)
i found a much easier way to do it than #tvl 's answer,
first create an access token with API access here: https://gitlab.com/profile/personal_access_tokens ,
then do:
wget --header 'PRIVATE-TOKEN: <token>' 'https://gitlab.com/<username>/<repo>/raw/master/path/to/file.ext'
i found the solution here.
If you would like to access a file from private GitLab, you could use the below approach which worked for me:)
Construct the URL:
https://url/api/v4/projects/projectId/repository/files/fileName/raw?ref=master&private_token=Generated_private_token
url is your Gitlab url ex: git.lab.com.
/api/v4/projects is a constant.
projectId is the projectId of your project, which you can find below the name of your project in gitlab.
/repository/files is again a constant.
fileName is the name of the file ex: sagar.txt
/raw?ref= is a constant and the value of ref can be master or any branch which you would like to take the file from. I am retrieving the file from Master.
Generated_private_token should be generated from gitlab, please follow the steps in mentioned in the link :
Generate Private Token

Cannot query Active Directory using ServerBind on non-domain computer in Windows PE

I have a need to write a .NET application which will query Active Directory while running in Windows PE on a computer which is not yet a member of the domain.
We are running this during a Microsoft Deployment Toolkit task sequence (note that MDT 2012 has been configured to load support for .NET into the WinPE environment - the .NET application is starting without any problems).
I am using the code below to bind to the domain:
DirectoryEntry entry = new DirectoryEntry(
path,
username,
password,
AuthenticationTypes.ServerBind | AuthenticationTypes.Secure);
I have tried a path both of the form:
LDAP://domainServer/dc=domain,dc=name
And also without a domain controller name as
LDAP://dc=domain,dc=name
I have also tried using a username both of the form domain\username and also just username.
The DirectoryEntry object seems to be constructed okay, but when I try to execute Console.Writeline(entry.Name) to confirm a valid connection has been made, I get the following exception:
System.Runtime.InteropServices.COMException (0x80005000): Unknown
error (0x80005000) at
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind() at
System.DirectoryServices.DirectoryEntry.get_Name()
I have tried other variations on this code, trying to execute LDAP queries with various filters, trying to rewrite it in VBScript, etc... but the code posted above is the simplest example I could come up with which reproduces the problem.
From what I have read, in a scenario like this you would always need to use AuthenticationTypes.ServerBind and that is why I am trying to specify the code within the ADSI LDAP path. But what is wrong with the code above? To me, it looks like it is passing all needed information in the parameters to the DirectoryEntry constructor.
There is a way to get it work, but it's not supported by Microsoft. This post helped me a lot. It works, tested and approved for a deployment of new computers :)
Get the ADSIxXX.inf from the zip file to C:\ADSI
Copy the following files from a Windows/System32 to C:\ADSI. Carefull of Architecture
x86 x64 -
adsldp.dll
adsmsext.dll
adsnt.dll
mscoree.dll
mscorier.dll
mscories.dll
Mount the bootimage.wim
No need to load Package (Your WinPE is already configured to load .NET API), juste add ADSI driver:
Dism /Image:C:\Mount /Add-Driver /Driver:C:\ADSI\ADSIxXX.inf /forceunsigned
No need to load his script
Unmount the bootimage.wim
Then it's done, if your .NET application is well implement ;)
I'm not sur the PIPE | is supported as an argument too, just set to AuthenticationTypes.Secure -
DirectoryEntry entry = new DirectoryEntry(
path,
username,
password,
AuthenticationTypes.ServerBind | AuthenticationTypes.Secure);
Link: http://www.deploymentresearch.com/Research/tabid/62/EntryId/74/ADSI-plugin-for-WinPE-4-0.aspx#AddComment

How can i define a Loginmodule from Glassfish asadmin?

I'm currently implementing a Glassfish realm backed by a neo4j DB, for which I've defined a Realm and a LoginModule class.
I can install the realm using the create-auth-realm asadmin command. But the realm is recognized by Glassfish only if it is associated to a LoginModule defined in the config/login.conf file.
For instance, in my case, I have to do the following:
Create the authentication realm: create-auth-realm --classname com.mycompany.security.MyRealm --property jaas-context=MyLoginModule myrealm and then
Define MyLoginModule in that config/login.conf file :
MyLoginModule {
fr.mycompany.security.MyLoginModule required;
};
I can edit the login.conf file by hand but would like to use an asadmin command to automate this step. Would you know of such an asadmin command ?
It seems that, at the moment, the Glassfish CLI does not support this.
Quote from here:
glassfish has a pretty good CLI (which is actually one of the reasons,
why I switched over from JBoss). However, there is no CLI cmd for
modifying the login.conf of an instance (i.e. add/remove an entry in a
reliable way).
I'm wondering about why the realm is not added/removed automatically
to/from the login.conf, when one creates/deletes a realm using the
create-auth-realm/delete-auth-realm command ...
I have requested for an update.

Problems consuming web service from groovy script

I'm having some problems trying to consume a web service from a groovy script. I'm using WSClient lib.
If I execute the example posted at groovy's website:
#Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.2')
import groovyx.net.ws.WSClient
proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize()
result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"
Works fine, but once I try to consume another service it crashes with this error:
INFO: Created classes: javac: no
source files Usage: javac
use -help for a list
of possible options 07-jul-2010
9:55:57
org.apache.cxf.endpoint.dynamic.DynamicClientFactory
createC lient GRAVE: Could not compile
java files for http://xxx:8080/x/services/xxx?wsdl.
Caught:
groovyx.net.ws.exceptions.InvokeException:
java.lang.NullPointerExceptio n
at groovy-ws.run(groovy-ws.groovy:13)
The code it's exactly the same (apart from wsdl url which correponds to one internal server). The main difference I found between them is that the second wsdl is RPC style while the first one isn't. I've read that there's some problems to consume RPC like webservices from groovy with WSClient lib. ¿Does anyone know how to consume RPC like webservices with WSClient? ¿Could anyone enlighten me please?
Thank you very much
There seems to be a bug in GroovyWS, documented here on their JIRA.
It's currently Unresolved and was added in 2010.
I'm personally getting the same error with anything other than the trivial example service, with Groovy 1.8.0, GroovyWS 0.5.2
Hopefully somebody can find the issue and fix it - WSClient could definitely be a great alternative to traditional CXF/JAXB
Don't use WSClient is the best answer I can give you. For anything but simple services I've found WSClient does not work well. Instead use what ever java based web service client your most comfortable with and call it from Groovy.

Resources