This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django_python3_ldap.ldap import connection | |
with connection() as c: | |
print(c.get_user(username="foo")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django_python3_ldap import ldap | |
from django.contrib.auth.decorators import login_required | |
@login_required | |
def ldap_seach(request): | |
# Because of login_required, this view is protected by the Django login screen. | |
# request.user will be the logged-in user. | |
if request.method == "POST": | |
# The user has submitted the search form of the user to look up. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
{- Supported HTTP methods. -} | |
data HttpMethod = GET | POST deriving (Read, Show) | |
{- A parsed HTTP request. --} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# your_project/your_app/ldap.py | |
import django_python3_ldap.utils.clean_user_data | |
def clean_user_data(model_fields): | |
""" | |
Transforms the user data loaded from | |
LDAP into a form suitable for creating a user. | |
""" | |
# Call the default handler. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ldap3.Connection( | |
ldap3.Server( | |
"ldap://msldap.uct.ac.za", | |
allowed_referral_hosts=[("*", True)], | |
), | |
user="01421894@wf.uct.ac.za", | |
password="password", | |
auto_bind=ldap3.AUTO_BIND_NO_TLS, | |
raise_exceptions=True, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
( | |
IF ( | |
( | |
SELECT COUNT(*) | |
FROM `people_person_contacts` | |
WHERE `from_person_id` = 12895 AND `to_person_id` = `people_person`.`id` | |
), | |
1, | |
IF ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT | |
`people_person`.`id`, | |
`people_person`.`date_created`, | |
`people_person`.`date_modified`, | |
`people_person`.`access`, | |
`people_person`.`thumbnail`, | |
`people_person`.`description`, | |
`people_person`.`short_description`, | |
`people_person`.`title`, | |
`people_person`.`first_name`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YourSearchAdapter(watson.SearchAdapter): | |
def get_title(self, obj): | |
return super().get_title(obj).lower() | |
def get_description(self, obj): | |
return super().get_description(obj).lower() | |
def get_content(self, obj): | |
return super().get_content(obj).lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
from watson import search as watson | |
search_engine_1 = watson.SearchEngine("engine_1") | |
search_engine_2 = watson.SearchEngine("engine_2") | |
class YourAppConfig(AppConfig): | |
name = "customer" | |
def ready(self): | |
search_engine_1.register(self.get_model("ModelA")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
from watson import search as watson | |
search_engine_1 = watson.SearchEngine("engine_1") | |
search_engine_2 = watson.SearchEngine("engine_2") | |
class YourAppConfig(AppConfig): | |
name = "customer" | |
def ready(self): | |
search_engine_1.register(self.get_model("ModelA")) |
NewerOlder