How to perform ldap search using wso2 esb? - search

I have written wso2esb configuration to perform "search" in an OpenLDAP server.
Below is my ESB configuration for the API:
<api context="/searchLDAP" name="searchLDAP">
<resource methods="GET" uri-template="/adap/{baseDN}">
<inSequence>
<log>
<property name="GET" value="searchLDAP"/>
</log>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property name="Authorization" scope="transport" value="Basic cn=Manager,dc=maxcrc,dc=com:secret"/>
<send>
<endpoint>
<http method="GET" uri-template="http://localhost:7070/adap/{baseDN}"/>
</endpoint>
</send>
</inSequence>
</resource>
</api>
I have LDAP installed in my local system. I also have ADAP which is configured to call LDAP server.
Here is the configuration to connect to LDAP server.
Base DN : ou=People,dc=maxcrc,dc=com
User DN : cn=Manager,dc=maxcrc,dc=com
Password: secret
The code for token Authentication is working fine and a token is being generated.
I have a curl script to test the ESB url:
curl -X GET -H "Content-Type: application/json" http://localhost:8280/searchLDAP/adap/cn=Abcxyz,ou=People,dc=maxcrc,dc=com
After running it, I don't get any response. No error message in logs as well.
However my back end URL given below works fine and I can perform search very well.
curl -X GET -H "Content-Type: application/json" http://localhost:7070/adap/cn=Abcxyz,ou=People,dc=maxcrc,dc=com
I also tried after hitting the ESB URL directly on browser but no luck.
Please check if there is something wrong with the API configuration or ESB URL.
Any help would be greatly appreciated.

You can use searchEntry operation in ldap connector to perform search. You can find the ldap connector at WSO2 Store.

Related

How does Kong Api Gateway http-log works

As per Kong documentation
**
$ curl -X POST http://kong:8001/apis/{api}/plugins \
--data "name=http-log" \
--data "config.http_endpoint=http://mockbin.org/bin/:id/" \
--data "config.method=POST" \
--data "config.timeout=1000" \
--data "config.keepalive=1000"
**
log will be create at http_endpoint.
I am unable to understand how does kong http-log works.
Suppose my request host is x.x.x.x and kong in installed in my local system,where should i look for log generated after adding http-log plugin.is http-log is accessible using console?
You have to create a listener on the location which is specified as config.http_endpoint. Endpoint has to handle config.method. It will receive a big JSON with all the log info in it.
Check example log JSON at click here
My Suggestion:
Best option here is to set this end point to the elastic search end point to receive all your logs and use Kibana UI on top of elastic to add the visualization to your log data.
HTTP Log -
Send request and response logs to an HTTP server.
the config.http_endpoint is your log server where you can view your logs

Is there a way to access webmin using APIs

I have installed webmin on my centos linux server.
I want to set a cron or list cron jobs using API which I can call through any python or php code.
I tried finding any such thing on internet and in webmin documentation, but couldnt find anything.
Has anyone tried this or knows how this thing can be implemented ?
I know I can create a PHP api or python api , which in turn can run shell commands to add crontab, but I am looking native-webmin API.
https://doxfer.webmin.com/Webmin/XML-RPC_Calls documents a way to perform rpc calls. You can, for example, execute such a call using curl with
curl --data #testcall -k https://root:changeme#192.168.0.100:10000/xmlrpc.cgi
where the content of testcall is
<?xml version="1.0"?>
<methodCall>
<methodName>useradmin::list_users</methodName>
<params>
<param>
<value>apiUser</value>
</param>
<param>
<value>apiKey</value>
</param>
</params>
</methodCall>

Spring Boot: Full authentication is required to access this resource

I am doing example of Spring Boot Security with wso2is server from this post https://github.com/angel-git/wso2is-springoauth, when I am trying to access resource with access token I am getting
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
I am generating access token by:
curl -u CLIENT_ID:CLIENT_SECRET-k -d
"grant_type=password&username=admin&password=admin" -H
"Content-Type:application/x-www-form-urlencoded"
https://localhost:9443/oauth2/token
and accessing resources by:
curl -H GET "Authorization: ACCESS_TOKEN"
http://localhost:8080/greeting
I found many solution on stackoverflow but unfortunately could not solve my issue
please help, thank you
I was getting the same error message for
"curl http://localhost:8080/spring4/beans" :
{"timestamp":1493591079040,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource.","path":"/spring4/beans"}
Setting the below property in application.properties bypassed the security check & I could use all the acuator endpoints:
management.security.enabled=false
Many thanx to Angel Gavalda who helped me to solved problem. I used following commands to generate access token and access resource
For Generating Access token:-
curl -k -d
'grant_type=client_credentials&client_id=yourClientId&client_secret=yourClientSecret'
https://localhost:9443/oauth2/token
For Accessing Resource:-
curl -k -H "Authorization: Bearer $ACCESS_TOKEN"
http://localhost:8080/greeting
When the answer above does not solve this issue change OAuthConfigurations/RemoveOAuthHeadersFromOutMessage to false in the file api-manager.xml.

How to configure IIS with IBM WebSphere Application Server Liberty Profile?

I am trying to setup IIS (version 8.x, windows 2008) in front of IBM WAS(Liberty Profile) server so that it can route all specific requests to IBM WebSphere application server(Liberty Profile).
I have already installed & configured following items :
Installed IBM WebSphere Application Server Liberty Core (Version 8.5.5)
Installed IBM MobileFirst Platform Server (Verison 7.1)
Installed WebServer Plugins for IBM WAS
Installed IBM WebSphere Customization Toolbox (Version 8.5)
I have also deployed one MobileFirst Runtime and it's working totally fine. Now the only step remaining is configuration with IIS.
I am following below link, But could not understand it thoroughly :
https://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tins_manualWebIIS.html
As I have installed IBM WAS Liberty Core, It did note come up with any IBM JAVA SDK. Is It required? How can I install IBM Java SDK for IBM WAS Liberty?
I am really lost about what should be the first step.
Edit on 24/09/2015 :
I downloaded & installed IBM Java SDK for Liberty Core.
I generated plugin-cfg.xml
I configured IIS with plugin-cfg.xml using this link : https://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tins_manualWebIIS.html
Now all application requests are redirecting to IBM WAS.
When I hit, localhost/HelloWorld/apps/services/www/HelloWorld/desktopbrowser/default/index.html, HelloWorld app is working totally fine.
Now the only problem is when I hit /worklightconsole, It is not able to get deployed application and adapters.
My plugin-cfg.xml looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<Config ASDisableNagle="false" AcceptAllContent="false" AppServerPortPreference="HostHeader" ChunkedResponse="false" FIPSEnable="false" IISDisableNagle="false" IISPluginPriority="High" IgnoreDNSFailures="false" RefreshInterval="60" ResponseChunkSize="64" SSLConsolidate="false" TrustedProxyEnable="false" VHostMatchingCompat="false">
<Log LogLevel="Error" Name=".\logs\defaultServer\http_plugin.log"/>
<Property Name="ESIEnable" Value="true"/>
<Property Name="ESIMaxCacheSize" Value="1024"/>
<Property Name="ESIInvalidationMonitor" Value="false"/>
<Property Name="ESIEnableToPassCookies" Value="false"/>
<Property Name="PluginInstallRoot" Value="."/>
<VirtualHostGroup Name="default_host">
<VirtualHost Name="*:443"/>
<VirtualHost Name="*:9443"/>
<VirtualHost Name="*:80"/>
<VirtualHost Name="*:9080"/>
</VirtualHostGroup>
<ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true" LoadBalance="Round Robin" Name="defaultServer_default_node_Cluster" PostBufferSize="0" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60">
<Server CloneID="89f03a0d-7c05-4c33-a82c-12da20477cdd" ConnectTimeout="5" ExtendedHandshake="false" MaxConnections="-1" Name="default_node_defaultServer0" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="localhost" Port="9080" Protocol="http"/>
<Transport Hostname="localhost" Port="9443" Protocol="https">
<Property Name="keyring" Value="keyring.kdb"/>
<Property Name="stashfile" Value="keyring.sth"/>
<Property Name="certLabel" Value="LibertyCert"/>
</Transport>
</Server>
<PrimaryServers>
<Server Name="default_node_defaultServer0"/>
</PrimaryServers>
</ServerCluster>
<UriGroup Name="default_host_defaultServer_default_node_Cluster_URIs">
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/RestProject/*"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/wladmin/*"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/HelloWorld/*"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/IBMJMXConnectorREST/*"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/worklightconsole/*"/>
</UriGroup>
<Route ServerCluster="defaultServer_default_node_Cluster" UriGroup="default_host_defaultServer_default_node_Cluster_URIs" VirtualHostGroup="default_host"/>
</Config>
I am getting following errors :
Failed request: /worklightconsole/services/management-apis/1.0/runtimes/HelloWorld/applications
Failed request: /worklightconsole/services/management-apis/1.0/runtimes/HelloWorld
Failed request: /worklightconsole/services/management-apis/1.0/runtimes/HelloWorld/adapters?offset=0&pageSize=15
Any help would be highly appreciated.
Just to summarize all the links and steps:
On the machine that you have IIS you have to install WebSphere plugin and WebSphere Customization Toolbox - follow steps provided in Configuring a web server plug-in for the Liberty profile and in Installing and using the WebSphere Customization Toolbox
You should be able to configure IIS automatically via Toolbox, if you cant for some reason, here are manual stepsConfiguring Microsoft Internet Information Services (IIS)
On your Liberty Core machine, you probably already have Java configured if the MobileFirst runtime is working fine, if not you have to download WebSphere Java SDK also via Installation Manager for details see Installing and uninstalling SDK Java Technology Edition Version 7.0 or 7.1 for Liberty
If your applications are working directly, but not via IIS, you have to generate new plugin configuration file in Liberty via jconsole (follow the steps in the first link) and copy it to the path pointed in the IIS WebSphere plugin configuration.

Change domain expire-date on all domains on Plesk 11 API

I have more than 100 domains on a Plesk 11 server, I created them on Default Service Plans, but they expire every year. I updated the default Service Plans and set Expiration date to Unlimited but how to I apply to all domains using Default Service Plans?
I have tried changing Service Plans and sync but domain Renewal date does not change.
Is there a way to do it using Plesk API?
via API-RPC:
# cat x.xml
<?xml version="1.0" encoding="UTF-8" ?>
<packet version="1.6.3.0">
<webspace>
<set>
<filter/>
<values>
<limits>
<limit>
<name>expiration</name>
<value>-1</value>
</limit>
</limits>
</values>
</set>
</webspace>
</packet>
# curl -kv -XPOST -H "HTTP_AUTH_LOGIN: admin" -H "HTTP_AUTH_PASSWD: password" -H "Content-Type: application/xml" -d #x.xml https://localhost:8443/enterprise/control/agent.php
via CLI:
# for sub in `ls /var/www/vhosts/` ; do /usr/local/psa/bin/subscription_settings -u $sub -expiration -1 ; done
You can easyly change subscription date by
Login in to plesk by reseller login details
Click on Subscriptions
Select any domain Click on Customized Then go to Bottom of page and
change to new coming date
Click Update and lock.
See this video for more:
https://www.youtube.com/watch?v=XkRfnJRpMdc

Resources