sqlalchemy-teradata icon indicating copy to clipboard operation
sqlalchemy-teradata copied to clipboard

AUTHMECH=LDAP

Open woel0007 opened this issue 10 years ago • 7 comments

Does the tdodbc driver or this SQLA Dialect support LDAP authentication to TD?

I scanned through the code quickly - I can't find anything that appears that it would allow setting the Logon Mechanism used.

woel0007 avatar Jul 14 '16 13:07 woel0007

@woel0007 ~~Short answer is the dialect doesn't support LDAP right now.~~ The tdodbc driver is from the python teradata library.

@woel0007 I may have spoken too soon. I've updated the dialect to handle extra parameters being passed in the connection string (see 129255b0100455b8a6f29044ad75cdcb4e8c3bad).

sandan avatar Jul 18 '16 18:07 sandan

The tdodbc component from the Teradata Python Library does support LDAP. You have to pass "authentication=LDAP" to the UdaExec::connect function either as a method argument or via the data source definition in an external configuration file.

escheie avatar Jul 18 '16 18:07 escheie

@escheie The connect arguments from the engine can be passed to the odbcConnect constructor (which is what is being used when the engine is created).

I'm not sure what processing is done for the authentication kwarg in UdaExec::connect but if all that needs to be done is to pass the authentication kwarg to odbcConnect, then you should be able to do it like so:

from sqlalchemy import create_engine
user = 'user'
pasw=user
host = 'host'

td_engine = create_engine('teradata://'+ user +':' + pasw + '@'+ host + '/' + '?authentication=LDAP')
print(td_engine)

Engine(teradata://user:***@host/?authentication=LDAP)

I'm not familiar with external authentication. Is there a way to verify if it worked?

sandan avatar Jul 18 '16 22:07 sandan

No handling of the authentication parameter is done in UdaExec so you can pass it straight through to the OdbcConnection constructor. The key and value is added to the connect string that is passed to ODBC driver SQLDriverConnectW function. Sounds like it should work with no changes.

escheie avatar Jul 19 '16 01:07 escheie

Sorry to comment on a closed issue, but can you pass in multiple parameters at a time? I'm trying to add LDAP authentication and also specify a driver but it seems I can only do one or the other.

teradata://user:@host/?authentication=LDAP/?driver=Teradata or teradata://user:@host/?authentication=LDAP?driver=Teradata

only seems to capture whichever parameter is entered first. I'm sure I'm missing something simple here.

richconboy avatar Jun 21 '17 15:06 richconboy

Shouldn't you be using an ampersand (&) between parameters in the connection URL?

mrbungie avatar Jun 22 '17 19:06 mrbungie

That does the trick! And just as I figured, it was incredibly simple. Appreciate the help!

richconboy avatar Jun 22 '17 20:06 richconboy