Query Active Directory using logged on users credentials Python3 - python

I'm creating a small application that queries Active Directory for computer names. Currently I am using the ldap3 module since it seems to one of the few supporting Python3, but I am open to alternatives.
Is there any way to use the currently logged on users credentials to authenticate to the LDAP server?
This way a user can run the program and get the computer names if they're logged in as a domain user, without having to enter their username/password each time.
More info about my environment:
Windows Domain
Python 3.4
Modules: ldap3, pywin32, pyqt4

Related

How to connect to sharepoint from a python script after Microsoft deprecates basic authentication and forces MFA?

I currently have a script in python using shareplum library which connects to our sharepoint to upload a specific file periodically. Currenly it's authenticating via an app password.
Recently I just saw this Microsoft notice that they will disable basic authentication including app passwords and they will be forcing MFA from 03/31/2023.
I've been looking for alternatives to keep using this kind of automated scripts to work with sharepoint files but I couldn't find anything...
What do you suggest?

I have installed python software on ubuntu machine i want to create multiple logins on ubuntu server on AWS EC2

I have Spun up Aws EC2 Ubuntu 18.0 instance I have installed python.
My requirements are.
I want to create multiple logins up to 50. login will happen simultaneously so VM must support multiple login
I want the users to login with the same ".ppkfile" and same public i/p but instead of logging in as root user. they need to login with their user names.
the installed python must be accessible for all 50 users.
Is there a way that I can achieve this? Kindly suggest me on how to proceed?
You can do so by creating the user-account manually for each user or writing shell script to automate it. You have to follow linux adduser command to create users. You can also create separate keys for each user or can use password based login as well. Follow the below link to achieve the same.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html
As for the python part, if it is installed at the system level and all the users can access it. You need root access to install python at system level. This is a duplicate question and has been asked here

Using windows authentication for a Django app served by linux box

I have Windows users that access a Django app that runs on a linux server. The question was asked, can that Django app use windows authentication to verify users? Or is it impossible since Django runs on a linux server.
The answer to your question is, "it depends." There are several different kinds of Windows Authentication, and it depends which you are using.
If you're logging into a company domain using Active Directory, then yes, you can use the same authentication for Django. I use a package called django-python3-ldap, which supports Active Directory; you can find it here:
https://github.com/etianen/django-python3-ldap
You'll have to work with your Microsoft Windows domain administrator to get the settings correct for your Active Directory LDAP server. Active Directory is Microsoft's brand name for its flavor of LDAP.
On the other hand, if you're using a local computer account, the answer is no, and if you're using a Microsoft Live account, the answer is... it's complicated!
Good luck.

Python Requests: Connect to Sharepoint online with 2-factor auth enabled

I would like to create a Python script to retrieve lists from Sharepoint Online and potentially update them. I can do all of this from the browser just fine. However, I'm having a hard time connecting to Sharepoint using the Requests module. When I navigate to https://mysharepoint.sharepoint.com, I get redirected to the https://login.microsoftonline.com to log in through my account. The login mechanism also requires two-factor authentication.
I'm not sure whether there's a way I could log in using Python at all at this point. Most of the packages I've tried have not been able to authenticate my user.

Single sign on to Django site via remote Active Directory

I developed an Intranet for a client using Django. The users sign on to their computers via Active Directory. Currently, I log them in via standard Django contrib.auth, and use Active Directory via custom login backends.
What I'd like is for users to be able to use SSO via their existing Active Directory login to be automatically logged into the Django site.
I understand that this should be done via REMOTE_USER (https://docs.djangoproject.com/en/dev/howto/auth-remote-user/), but the documentation says: "where the Web server sets the REMOTE_USER environment variable". This assumes that the Django site and the authentication server are on the same server, no?
In my case, the Django site is running on a Linux + Apache server and the Active Directory on another Windows machine (there's actually 2 different AD servers we use to log people in), so I don't know how the REMOTE_USER env variable would be set.
The users are all using Windows machines.
The magic word herefore is kerberos authentication.
Your user does not authenticate against your django application but against your webserver. Your intranet probably has a kerberos service running, that authenticates your user for you and just gives you a user name in REMOTE_USER if he is authenticated.
You can then search your LDAP for specific Access Rights or have an own database with special access rights.
Here is a short article from CentOS. It is very important what your environment looks like, so all I cann do is show you the direction ;-)
http://wiki.centos.org/HowTos/HttpKerberosAuth

Categories