LDAP search in Grafana doesn't work - authentication

I'm struggling for a while to make Grafana LDAP work as I can't find appropriate search filter. In AD, both groups Grafana-Admin/User have a group as a member and that group have users which need to authenticate to Grafana.
To simplify, my user sys22 is in a group called Graylog, group Graylog is a Member Of group Grafana. And, I want to use group Grafana in LDAP configuration.
verbose_logging = true
[[servers]]
host = "dc-01.corp.domain.com"
port = 389
use_ssl = false
ssl_skip_verify = true
bind_dn = "CN=Grafana-Auth,OU=ApplicationAccount,OU=SE,OU=Admin,DC=corp,DC=domain,DC=com"
bind_password = 'pass1'
search_filter = "(&(objectCategory=Person)(sAMAccountName=%s)"
search_base_dns = ["dc=corp,dc=domain,dc=com"]
# group_search_filter = "(member:1.2.840.113556.1.4.1941:=%s)"
# group_search_filter_user_attribute = "distinguishedName"
# group_search_base_dns =
["OU=Group,OU=SE,OU=Unit,DC=corp,DC=domain,DC=com"]
[servers.attributes]
name = "givenName"
surname = "sn"
username = "sAMAccountName"
member_of = "distinguisedName"
email = "mail"
[[servers.group_mappings]]
group_dn = "CN=Grafana-
Admin,OU=Access,OU=Group,OU=SE,OU=Unit,DC=corp,DC=domain,DC=com"
org_role = "Admin"
[[servers.group_mappings]]
group_dn = "CN=Grafana-
User,OU=Access,OU=Group,OU=SE,OU=Unit,DC=corp,DC=domain,DC=com"
org_role = "Editor"
[[servers.group_mappings]]
group_dn = "*"
org_role = "Viewer"
Applying various filters doesn't help and all the time I am getting
lvl=eror msg="Invalid username or password" logger=context userId=0 orgId=0
uname= error="Invalid Username or Password"
t=2018-05-18T08:01:02+0200 lvl=info msg="Request Completed" logger=context
userId=0 orgId=0 uname= method=POST path=/login status=401
remote_addr=X.X.X.X time_ms=13 size=98
referer=http://graylogprod.corp.domain.com/grafana/login
Any advice I'll much appreciate...
Thank you,
B

An issue in my case was in the infrastructure of the AD. Grafana doesn't support nested groups and users couldn't be found.

Related

How to delete some data from External Table Databricks

I am trying to delete some data from Azure SQL from Databricks using JDBC, it generate error each time. I have very simple query delete from table1 where date>'2022-05-01'.
I searched many documents online but did not find any appropriate solution for this. Please find below code.
jdbcUsername = "userName"
jdbcPassword = "password" #these from Azure Key Vault
jdbcHostname = "host server name"
jdbcPort = "1433"
jdbcDatabase = "db_test"
jdbcUrl = "jdbc:sqlserver://{0}:{1};database={2}".format(jdbcHostname, jdbcPort, jdbcDatabase)
connectionProperties = {
"user" : jdbcUsername,
"password" : jdbcPassword,
"driver" : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
}
pushdown_delete_query = f"(delete from table1 where date>'2022-05-01') table_alias"
print(pushdown_delete_query)
spark.read.jdbc(url=jdbcUrl, table=pushdown_delete_query, properties=connectionProperties)
the query return error com.microsoft.sqlserver.jdbc.SQLServerException: A nested INSERT, UPDATE, DELETE, or MERGE statement must have an OUTPUT clause

how to change the created by <user> in log to OdooBot when creating a record using odoo external API

I'm trying to create a new lead from external landing page
The code work as expected so far on Odoo 13.0+e-20200524
url = ODOO_URL
db = ODOO_DB
username = ODOO_USERNAME
password = ODOO_PASSWORD
kwargs = {
'name': 'hello world',
}
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
print(uid)
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [{
'name': kwargs.get('name'),
'user_id': 1,
}])
print(id)
But the log of the lead showing that my user created that lead (which is properly right)
Change the created user to OdooBot in the view - screenshot
My question is:
How can I change the created user to OdooBot instead of my user?
PS: I already searched around and tried bellow parameters without luck:
'user_login': "OdooBot",
'create_uid': [1],
'write_uid': [1],
uid represent a key role of User to create a record using xmlrpc.
You can change uid and it will log with that User.

Terraform aws_cognito_identity_pool : what should be the client id and provider name?

error : "cognito_identity_providers.0.client_id must contain only alphanumeric characters and underscores"
This problem is from the client_id and provider_name on the aws_cognito_identity_pool resource . Where do we get these values. Terraform is not following AWS naming. I have tried Pool id and Pool ARN. but those don't work I also tried App client id
The sample provided in documentation below is not clear
cognito_identity_providers {
client_id = "6lhlkkfbfb4q5kpp90urffae"
provider_name = "cognito-idp.us-east-1.amazonaws.com/us-east-1_Tv0493apJ"
server_side_token_check = false
}
It should look like this:
cognito_identity_providers {
client_id = "${aws_cognito_user_pool_client.YOURCLIENT.id}"
provider_name = "${aws_cognito_user_pool.YOURPOOL.endpoint}"
server_side_token_check = false
}
The client_id and provider_name should be provided as below,
cognito_identity_providers {
client_id = "${aws_cognito_user_pool_client.client.id}"
provider_name = "cognito-idp.us-east-1.amazonaws.com/${aws_cognito_user_pool.ur_pool.id}"
server_side_token_check = true
}

Grails joinTable query issue

I have a User domain and a Role domain and a working joinTable coded on the User side as
static hasMany = [ roles: Role ]
...
static mapping = {
table 'user_data'
id column: 'employee_number', name: 'employeeNumber', generator: 'assigned', type: 'int'
version false
sort 'lastName'
roles joinTable: [ name: 'user_role' ]
}
I am trying to query the database to pull all users with a security officer role with
def roleInstance = Role.find { name == 'security_officer' }
def secList = User.findAll("from User as u where u.roles = :roleInstance", [roleInstance:roleInstance])
But I am getting the error
Class: com.microsoft.sqlserver.jdbc.SQLServerException
Message: The value is not set for the parameter number 1.
What am I doing wrong?
I figured it out with a bunch of guess and checking.
def roleInstance = Role.findByName("security_officer")
def query = User.where {
roles {
id == roleInstance.id
}
}
def securityOfficerList = query.list()
Roles is a hasMany relationship so I think following should work.
def secList = User.findAll("from User as u where u.roles in (:roleInstance)", [roleInstance:[roleInstance]])
User has many roles, so in query you can't use u.roles = roleInstance.Try to use in [list of roles] or you can try the following query:
def secList = User.findAll("from User as u where u.roles in (from Role r where r.name=:roleInstance)", [roleInstance:roleInstance])

Odoo how to create or update record using XML

I have read Odoo documentation for creating new record. It uses XML RPC.
final Integer id = (Integer)models.execute("execute_kw", asList(
db, uid, password,
"res.partner", "create",
asList(new HashMap() {{ put("name", "New Partner"); }})
));
So is it possible to create new record only using XML message.
Thanks.
yes it is possible. here is the documenttation
and here is an example to create customer record using just a python file.
import xmlrpclib
username = 'admin' #the user
pwd = 'admin' #the password of the user
dbname = 'odoo' #the database
# Get the uid
sock_common = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
partner = {
'name': 'atul arvind',
'phone': '8000111234'
}
partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
It will return newly created record's id.
hope it helps.