So, I see 2 options :
1) Define a common user that has the required level of access to both ldap
server so you can query both server doesn't matter which server user are
autheticated to...
2) Use user credentials to access data you need... This is actually is not
actually what ldap_auth is doing, but once ldap_auth has grant access to
user, you may then spawn other query to ldap server using user credentials
which you know that are correct... You can then update what ever you want
in your database from ldap_auth since it already has db available inside
the module. Though this requires more work since it is not working out of
the box, you have to code that inside ldap_auth yourself... Which even if
you code it as another module and import it, you will have to modify
ldap_auth contrib each time you upgrade web2py, since your hack will surely
not make it to the contrib as it is to specific...

Option 1 is the best to me... There is even option 0 which could be to have
only one LDAP instance, since having more then one inside the same
organisation is to me a non sens and goes against the idea of role of LDAP
instance...

Richard

On Thu, Dec 10, 2015 at 11:50 AM, Jonathan R <[email protected]> wrote:

> It's what I'm using right now (I can log with users from both servers) but
> I use the same credentials to process the queries that gather datas for my
> app (list of users, list of computers,...) and I need to know on which
> server the user is authenticated to in order to use the correct information
> for my queries.
> I'm seeing 2 ways:
> - automatically determine which ldap_auth was successful (I posted a
> question on the group for this as I linked before in this thread)
> - let the user decide and try auth only on the server the user chose.
>
> but I can't get any of these to work.
>
> On Wednesday, December 9, 2015 at 11:49:32 AM UTC-5, Richard wrote:
>>
>> What about setting 2 ldap authentication ?
>>
>> In web2py you can login with multiple login methods and web2py use them
>> in the order they are specified in auth.settings.login_methods... If
>> password fail for one it tries with the other...
>>
>> Here my settings :
>> auth.settings.login_methods = \
>>     [auth,
>>      ldap_auth(...)]
>>
>> You may try just to do :
>> auth.settings.login_methods = \
>>     [ldap_auth(...),
>>      ldap_auth(...)]
>>
>> You define you 2 differents ldap servers...
>>
>> Richard
>>
>>
>>
>> On Tue, Dec 8, 2015 at 4:19 PM, Jonathan R <[email protected]> wrote:
>>
>>> I have two distinct sources of authentication ( 2 ldap servers) and I
>>> use the credentials provided by the user to perform the query that gather
>>> information on the ldap server on which the user is authenticated.
>>> In an effort to follow the DRY concept my function that gather
>>> information can query both server and chose the correct one by using a
>>> boolean set to True for one server and False for the other.
>>> I asked another question on this group about the best way to determine
>>> which auth_method was successful (when using
>>> auth.settings.auth_methods[auth_ldap(server 1), auth_ldap(server2)]) but no
>>> one has provided an answer yet.
>>> That let me with the present option to customize the login form to let
>>> the user chose on which server launch the query.
>>>
>>> I asked about the variable storing the value before processing the form
>>> because I was exploring on the jQuery side ( onchange event) which doesn't
>>> seems to be able to do the job.
>>>
>>> I hope I clarified the situation :p
>>>
>>> On Tuesday, December 8, 2015 at 3:18:04 PM UTC-5, Richard wrote:
>>>>
>>>> :)
>>>>
>>>> For what...
>>>>
>>>>
>>>>
>>>> On Tue, Dec 8, 2015 at 2:18 PM, Jonathan R <[email protected]> wrote:
>>>>
>>>>> I need to have this radio button,
>>>>> is there a variable that stores the value of the radio button before
>>>>> processing the form ?
>>>>>
>>>>> On Tuesday, December 8, 2015 at 11:03:40 AM UTC-5, Richard wrote:
>>>>>>
>>>>>> You should have a look at web2py auth... I guess no one really need
>>>>>> to customize login form... There is surely a way to customize it, and you
>>>>>> seems to have found a way... You may also, ask yourself about why you do
>>>>>> that and if you really need to do it... Or could it be crafted
>>>>>> differently... For instance would your user really want to change setting
>>>>>> at each login?? Maybe you can have a preference profile page for each 
>>>>>> user
>>>>>> to them set there prefered way of login...
>>>>>>
>>>>>> Richard
>>>>>>
>>>>>> On Tue, Dec 8, 2015 at 10:56 AM, Jonathan R <[email protected]> wrote:
>>>>>>
>>>>>>> Yes I did, and nothing changed on the login screen, I still had None
>>>>>>> displayed instead of the radio button.
>>>>>>>
>>>>>>> I feel like there is a simple easy way to add a field in the login
>>>>>>> screen and save it but I can't see it...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Monday, December 7, 2015 at 9:42:51 PM UTC-5, Richard wrote:
>>>>>>>>
>>>>>>>> Did you try by simply specify :
>>>>>>>>>
>>>>>>>>> Field('radio_button', ..., readable=True, writable=True)
>>>>>>>>>
>>>>>>>>
>>>>>>>> ?
>>>>>>>>
>>>>>>>> Richard
>>>>>>>>
>>>>>>>> On Mon, Dec 7, 2015 at 5:19 PM, Jonathan R <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> I successfully added the radio button i wanted on my login page
>>>>>>>>> but instead of using a column in the auth_user table I only created a 
>>>>>>>>> radio
>>>>>>>>> button that will assign its value in a session variable. To do so I 
>>>>>>>>> need to
>>>>>>>>> modify the if form.accepts(): block to gather the value on submission 
>>>>>>>>> but
>>>>>>>>> I'm not sure where to find this piece of code (or what should be in a
>>>>>>>>> custom one to keep the authentication process working).
>>>>>>>>>
>>>>>>>>> my default.py :
>>>>>>>>> user():
>>>>>>>>>
>>>>>>>>> if request.args(0)== "login":
>>>>>>>>>     form=auth()
>>>>>>>>>
>>>>>>>>> form.elements()[0].insert(0,LABEL('text1',_class='radioButton'))
>>>>>>>>>
>>>>>>>>> form.elements()[0].insert(0,INPUT(_type='radio',_class='radioButton',_value='text1'))
>>>>>>>>>     #same for all values
>>>>>>>>>
>>>>>>>>>     #frest of the form (username and password) same as Richard
>>>>>>>>> implementation
>>>>>>>>>
>>>>>>>>>     return dict(form=form)
>>>>>>>>>
>>>>>>>>> [...]
>>>>>>>>>
>>>>>>>>> then if I want to gather the data in a session variable I'll have
>>>>>>>>> to change the behavior of the auth() form on accepts:
>>>>>>>>>
>>>>>>>>> if form.accepts(request,session):
>>>>>>>>>     session.radioButtonValue = form.vars.radioButton
>>>>>>>>>
>>>>>>>>> but this will stop the auth to process the rest of the form but I
>>>>>>>>> don't know what are the mandatory steps to add (couldn't locate the
>>>>>>>>> original auth accepts process)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, December 4, 2015 at 4:45:52 PM UTC-5, Jonathan R wrote:
>>>>>>>>>>
>>>>>>>>>> Hi everyone,
>>>>>>>>>> I'm trying to add a radio button on my login form to let the user
>>>>>>>>>> decide which authentication method he wants to use.
>>>>>>>>>>
>>>>>>>>>> I added a field in the auth_user table and i try to display the
>>>>>>>>>> corresponding radio button in my login page as follow:
>>>>>>>>>>
>>>>>>>>>> in bd.py
>>>>>>>>>>
>>>>>>>>>> [......]
>>>>>>>>>>
>>>>>>>>>> auth.settings.extra_fields['auth_user']=[Field]('choice',
>>>>>>>>>> requires=IS_IN_SET(['choice 1','choice
>>>>>>>>>> 2']),widget=SQLFORM.widgets.radio.widget),]
>>>>>>>>>>
>>>>>>>>>> auth.define_tables(username=True)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> [...]
>>>>>>>>>>
>>>>>>>>>> in user.html
>>>>>>>>>>
>>>>>>>>>> [...]
>>>>>>>>>>
>>>>>>>>>> {{form=auth.login()}}
>>>>>>>>>>
>>>>>>>>>> [...]
>>>>>>>>>>
>>>>>>>>>> {{=form.custom.begin}}
>>>>>>>>>> Method to Use:
>>>>>>>>>> {{=form.custom.widget.choice}}
>>>>>>>>>> </br>
>>>>>>>>>> Username:
>>>>>>>>>> {{=form.custom.widget.username}}
>>>>>>>>>> </br>
>>>>>>>>>> Password:
>>>>>>>>>> {{=form.custom.widget.password}}
>>>>>>>>>> {{=form.custom.submit}}
>>>>>>>>>> {{=form.custom.end}}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> [...]
>>>>>>>>>>
>>>>>>>>>> This displays correctly the Username and password fields as text
>>>>>>>>>> and password field but instead of the radio Button the app return 
>>>>>>>>>> None.
>>>>>>>>>>
>>>>>>>>>> I checked the db table and the field is created.
>>>>>>>>>>
>>>>>>>>>> What am I doing wrong ?
>>>>>>>>>>
>>>>>>>>>> Thank you for your help.
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>> Resources:
>>>>>>>>> - http://web2py.com
>>>>>>>>> - http://web2py.com/book (Documentation)
>>>>>>>>> - http://github.com/web2py/web2py (Source code)
>>>>>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>>>>>> ---
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "web2py-users" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to [email protected].
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>> Resources:
>>>>>>> - http://web2py.com
>>>>>>> - http://web2py.com/book (Documentation)
>>>>>>> - http://github.com/web2py/web2py (Source code)
>>>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "web2py-users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>>>> Resources:
>>>>> - http://web2py.com
>>>>> - http://web2py.com/book (Documentation)
>>>>> - http://github.com/web2py/web2py (Source code)
>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to