Web.Contents() with username, password and domain - powerquery

I'm using the following mcode to get data from the web
Source = Web.Contents(url,[Headers=[Authorization="Bearer " & XXX],Timeout=#duration(0, 0, 0 ,1),IsRetry=false])
However, XXX needs to log in to the web and then go to the DEV tool to get it
Is there a way to use web.contents with username, password and domain instead of the above method?
I tried
Source = Web.Contents(url,[RelativePath = "restapi/v1/token?" & "username=xxx" & "&password=xxx" & "domain=xxx"])

Use Web.Contents like this:
Source = Web.Contents(
url,
[
RelativePath = "restapi/v1/token",
Query =
[
username = "xxx",
password = "yyy"
domain = "zzz"
],
Timeout = #duration(0, 0, 0 ,1),
IsRetry = false
]
)

Related

Creating cross region autonomous database failing with 'message': "The following tag namespaces / keys are not authorized or not found: 'oracle-tags'"

Need help in creating cross region standby database via python have tried creating with
oci.database.models.CreateCrossRegionAutonomousDatabaseDataGuardDetails
I am unable to find an example for the same so i tried with whatever i can find through sdk documentation
response = oci_client.get_autonomous_database(autonomous_database_id=primary_db_id)
primary_db_details = response.data
def create_cross_region_standby_db(db_client, primary_db_details: oci.database.models.AutonomousDatabase):
adw_request = oci.database.models.CreateCrossRegionAutonomousDatabaseDataGuardDetails()
adw_request.compartment_id = primary_db_details.compartment_id
adw_request.db_name = primary_db_details.db_name
adw_request.data_storage_size_in_tbs = primary_db_details.data_storage_size_in_tbs
adw_request.data_storage_size_in_gbs = primary_db_details.data_storage_size_in_gbs
adw_request.cpu_core_count = primary_db_details.cpu_core_count
adw_request.db_version = primary_db_details.db_version
adw_request.db_workload = primary_db_details.db_workload
adw_request.license_model = primary_db_details.license_model
adw_request.is_mtls_connection_required = primary_db_details.is_mtls_connection_required
adw_request.is_auto_scaling_enabled = primary_db_details.is_auto_scaling_enabled
adw_request.source_id = primary_db_details.id
adw_request.subnet_id = <standby subnet id>
adw_response = db_client.create_autonomous_database(create_autonomous_database_details=adw_request)
print(adw_response.data)
adw_id = adw_response.data.id
oci.wait_until(db_client, db_client.get_autonomous_database(adw_id), 'lifecycle_state', 'AVAILABLE')
print("Created ADW {}".format(adw_id))
return adw_id
create_cross_region_standby_db is done using standby region credentials. Creation of primary db in the same region works fine.

Sphinx + Oracle : Data source name not found error

I want to connect to remote oracle database server and index some data from there with sphinx search engine. My OS is ubuntu 16.04 and I havc installed sphinx on it and tested it with local mysql database and everthing was ok (All the data indexed and I could search and results was correct) . I also have installed unixODBC and tested it with isql tool to remote access to oracle database server and every thing was ok, but when I want to index data with indexer command of sphinx this error occure:
sql_connect: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
Here is source block of my sphinx.conf file:
source src2
{
type = odbc
sql_host = hostName
sql_user = user
sql_pass = pass
sql_db = dbname
sql_port = 1521
odbc_dsn = DSN = mydsn; Driver={Oracle};Dbq=hostname:1521/dbname;Uid=user;Pwd=pass
sql_query = \
SELECT tableId, Name \
FROM sampleTable
}
And odbc.ini file:
[mydsn]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
BindAsFLOAT = F
CloseCursor = F
DisableDPM = F
DisableMTS = T
Driver = Oracle
DSN = mydsn
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MaxLargeData = 0
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = MYDATABASE
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
DisableRULEHint = T
UserID = user
Password = pass
StatementCache=F
CacheBufferSize=20
UseOCIDescribeAny=F
SQLTranslateErrors=F
MaxTokenSize=8192
AggregateSQLType=FLOAT
and odbcinst.ini file :
[Oracle]
Description= ODBC for Oracle
Driver = /opt/oracle/instantclient_12_2/libsqora.so.12.1
Setup =
FileUsage = 1
CPTimeout =
CPReuse = /usr/local/etc/odbcinst.ini
Try
odbc_dsn = DSN=mydsn;
i.e. w/o spaces around = after the DSN and since you have everything else specified in the ini file just the DNS should be enough. You also need only sql_query out of the rest sql_*. Like this:
source src2
{
type = odbc
odbc_dsn = DSN=mydsn;
sql_query = \
SELECT tableId, Name \
FROM sampleTable
}

Erlang Heroku RabbitMQ

i run in terminal command
heroku config:get RABBITMQ_BIGWIG_RX_URL --app app1
give me a string
amqp://Ajwj23X3:nsi3sC#leaping-charlock-1.bigwig.lshift.net:18372/Hbau2x3d
I copy login,password,url,port to erlang code
-record(amqp_params_network, {username = <<"Ajwj23X3">>,
password = <<"nsi3sC">>,
virtual_host = <<"/">>,
host = "leaping-charlock-1.bigwig.lshift.net",
port = 18372,
channel_max = 0,
frame_max = 0,
heartbeat = 0,
connection_timeout = infinity,
ssl_options = none,
auth_mechanisms =
[fun amqp_auth_mechanisms:plain/3,
fun amqp_auth_mechanisms:amqplain/3],
client_properties = [],
socket_options = []}).
But when i run program and connection false
How correctly write amqp_params_network in erlang for heroku rabbitqm?
-record is the definition of the record type, and the values contained there are just defaults. It would be rather unusual to hard-code connection parameters as defaults for the record, even more so when the record definition is provided by an external library.
Instead, construct a record instance with the required data:
Params = #amqp_params_network{username = <<"Ajwj23X3">>,
password = <<"nsi3sC">>,
host = "leaping-charlock-1.bigwig.lshift.net",
port = 18372},
and use that instance when connecting:
{ok, Connection} = amqp_connection:start(Params),

Configuring grails spring security ldap plugin

here is a part of my perl cgi script (which is working..):
use Net::LDAP;
use Net::LDAP::Entry;
...
$edn = "DC=xyz,DC=com";
$quser ="(&(objectClass=user)(cn=$username))";
$ad = Net::LDAP->new("ip_address...");
$ldap_msg=$ad->bind("$username\#xyz.com", password=>$password);
my $result = $ad->search( base=>$edn,
scope=>"sub",
filter=>$quser);
my $entry;
my $myname;
my $emailad;
my #entries = $result->entries;
foreach $entry (#entries) {
$myname = $entry->get_value("givenName");
$emailad = $entry->get_value("mail");
}
So basically, there is no admin/manager account for AD, users credentials are used for binding. I need to implement the same thing in grails..
+Is there a way to configure the plugin to search several ADs, I know I can add more ldap IPs in context.server but for each server I need a different search base...
++ I dont wanna use my DB, just AD. User logins through ldap > I get his email, and use the email for another ldap query but that will probably be another topic :)
Anyway the code so far is:
grails.plugin.springsecurity.ldap.context.managerDn = ''
grails.plugin.springsecurity.ldap.context.managerPassword = ''
grails.plugin.springsecurity.ldap.context.server = 'ldap://address:389'
grails.plugin.springsecurity.ldap.authorities.ignorePartialResultException = true
grails.plugin.springsecurity.ldap.search.base = 'DC=xyz,DC=com'
grails.plugin.springsecurity.ldap.authenticator.useBind=true
grails.plugin.springsecurity.ldap.authorities.retrieveDatabaseRoles = false
grails.plugin.springsecurity.ldap.search.filter="sAMAccountName={0}"
grails.plugin.springsecurity.ldap.search.searchSubtree = true
grails.plugin.springsecurity.ldap.auth.hideUserNotFoundExceptions = false
grails.plugin.springsecurity.ldap.search.attributesToReturn =
['mail', 'givenName']
grails.plugin.springsecurity.providerNames=
['ldapAuthProvider',anonymousAuthenticationProvider']
grails.plugin.springsecurity.ldap.useRememberMe = false
grails.plugin.springsecurity.ldap.authorities.retrieveGroupRoles = false
grails.plugin.springsecurity.ldap.authorities.groupSearchBase ='DC=xyz,DC=com'
grails.plugin.springsecurity.ldap.authorities.groupSearchFilter = 'member={0}'
And the error code is: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1
And it's the same code for any user/pass I try :/
Heeeeelp! :)
The most important thing with grails and AD is to use ActiveDirectoryLdapAuthenticationProvider rather than LdapAuthenticationProvider as it will save a world of pain. To do this, just make the following changes:
In resources.groovy:
// Domain 1
ldapAuthProvider1(ActiveDirectoryLdapAuthenticationProvider,
"mydomain.com",
"ldap://mydomain.com/"
)
// Domain 2
ldapAuthProvider2(ActiveDirectoryLdapAuthenticationProvider,
"mydomain2.com",
"ldap://mydomain2.com/"
)
In Config.groovy:
grails.plugin.springsecurity.providerNames = ['ldapAuthProvider1', 'ldapAuthProvider2']
This is all the code you need. You can pretty much remove all other grails.plugin.springsecurity.ldap.* settings in Config.groovy as they don't apply to this AD setup.
Documentation:
http://docs.spring.io/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#ldap-active-directory

Grails Spring Security 2.0 Active Directory authentication using user's group

I used dsquery for receive informations about my login in AD and I received information about name of group which I belong.
-name
CN=Surname Name I,OU=CITY,OU=FOLDER,OU=Users,DC=domain,DC=com
-group
CN=Name-of-Group Using Spaces, OU=Department ,OU=Folder_two,OU=Folder_one,OU=Groups,DC=domain,DC=com
So, I want to make accepting login only for me or users who consist in my group (
CN=Name-of-Group Using Spaces
). Here is my
Config.groovy
grails.plugin.springsecurity.ldap.context.managerDn = 'Surname Name I,OU=CITY,OU=FOLDER,OU=Users,DC=domain,DC=com'
grails.plugin.springsecurity.ldap.context.managerPassword = 'password'
grails.plugin.springsecurity.ldap.context.server = 'ldap://server:xxx/'
grails.plugin.springsecurity.ldap.authorities.ignorePartialResultException = true
grails.plugin.springsecurity.ldap.search.base = 'DC=domain,DC=com'
grails.plugin.springsecurity.ldap.search.filter="(&(sAMAccountName={0})(objectclass=user))"
grails.plugin.springsecurity.successHandler.defaultTargetUrl = '/view/index'
grails.plugin.springsecurity.ldap.search.searchSubtree = true
grails.plugin.springsecurity.ldap.auth.hideUserNotFoundExceptions= false
grails.plugin.springsecurity.providerNames=['ldapAuthProvider']
grails.plugin.springsecurity.securityConfigType = 'Annotation'
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/view/index':['IS_AUTHENTICATED_FULLY']
// '/view/index':['ROLE_Name-of-Group Using Spaces'] - this is what I tryed to use also and Its not working
]
this is working config, but the problem is that any user from domain has access.
here is solution:
grails.plugin.springsecurity.ldap.context.managerDn = 'Surname Name I,OU=CITY,OU=FOLDER,OU=Users,DC=domain,DC=com'
grails.plugin.springsecurity.ldap.context.managerPassword = 'password'
grails.plugin.springsecurity.ldap.context.server = 'ldap://server:xxx/'
grails.plugin.springsecurity.ldap.authorities.ignorePartialResultException = true
grails.plugin.springsecurity.ldap.search.base = 'DC=domain,DC=com'
grails.plugin.springsecurity.ldap.search.filter="(&(sAMAccountName={0})(|(memberOf=CN=Name-of-Group #1 Using Spaces, OU=Department ,OU=Folder_two,OU=Folder_one,OU=Groups,DC=domain,DC=com)(memberOf=CN=Name-of-Group #2 Using Spaces, OU=Department ,OU=Folder_two,OU=Folder_one,OU=Groups,DC=domain,DC=com)))"
grails.plugin.springsecurity.ldap.search.searchSubtree = true
grails.plugin.springsecurity.ldap.auth.hideUserNotFoundExceptions = false
grails.plugin.springsecurity.providerNames=['ldapAuthProvider']
grails.plugin.springsecurity.securityConfigType = "Annotation"
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/**': ['isFullyAuthenticated()']
]
authentication only for members of groups "Name-of-Group #1 Using Spaces" and "Name-of-Group #2 Using Spaces". No need "%20"

Resources