Python SharePoint On-Premise Access List

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what up y'all i am blue and today we're going to be talking about python connecting to a sharepoint on-prem so i have made some other videos in the past are related to python um accessing a let's say a sharepoint list or downloading um files from sharepoint so on and so on well one of the things that has came up from a few of the viewers has been like hey how do we connect to sharepoint on-prem and that's slightly different so the code that i put together only works for the office 365 version right like the cloud version of sharepoint it does not work for on-prem um so because we got a request and one one of the viewers so shout out to will he actually reached out to me and asked me if i could help him out um on on this project he was having issues so as we reviewed what you know tested out his code that he had we realized that hey your company is using a sharepoint on-prem this doesn't work and because i got other requests as well i decided to you know what let me go ahead and create a video for it but before i create a video video i first needed to set up a sharepoint i need to you know get a vm set up have sharepoint installed let's just say with a pain in the but nevertheless i did it for y'all hopefully this helps you out because man it was a pain in the ass to get sharepoint set up on my vm but nevertheless i did it i got to test it out and it works all right guys before we get started you can give me a like give me a follow appreciate it man much much appreciative and let's get started all right guys let's take a look at the source code so ultimately this source code is the same source code that i used for a previous project the previous video which is the python sharepoint list right you know python access connecting to sharepoint and be able to access um a sharepoint list now that code how i mentioned only works for the cloud version of sharepoint the office 365 version it does not work for on-prem so what we're going to do we're going to keep we're going to use the same code we're going to make some smart tweaks the small tweaks that we make is what is what's going to allow us to connect to the on-prem and then of course to be able to access in this case um the sharepoint list um keep in mind though as you authenticate on the on this message that i'm about to show you this works for the other video that i have made as well which relates to downloading files from sharepoint in this case it will be sharepoint on-prem but be able to download files or upload files all of that will still be the same the only major difference in this case of course is more so the um the authentication piece of it so let's let's kind of walk through what needs to change and uh to make it work so but before we get started let me just kind of show you real quick so this is the the sharepoint that i created i just call it sharepointdev and it's on my a vm that i'm that i set up and i created a list and i try to mimic this list kind of similar to what i had before on my other video so i have a client list and we have um the name or title you know mark and then of course street city postal state right that's kind of same information i had in my other video as well um and that's the goal right the goal here is we want to connect to this the site and the site is called the development which is the same of what i created in the previous video so i try to keep everything the same so everything's you know from a source code that i have right now too for my testing should all work the same the only difference is i need to get the authentication piece we need to tweak that piece so let's go ahead and make those small changes um in this case we're going to start off in the sharepoint dot py file and that's where we're going to make our changes so we're not dealing with office 365 anymore uh you know what before i get started let me make this bigger to make sure y'all could see it yeah there it goes all right cool so since we're not dealing with office 365 in this case it's on-prem we don't need to import this in so get that deleted i don't need the version of sharepoint either in this case that could go away um what i do need to bring in is going to be the request ntldm so this this um this is part of the request package so um by default when you install sharepump shareplump installs other packages along with it requests being one of the packages that gets installed well this is all it's part of that package so you know as long as long as the request is installed in your virtual environment this you you know you'll be able to import this in http ntlm so if you're not familiar with ntlm pretty much is a it's microsoft's authentication it's what is it called microsoft network authentication protocol uh i don't know the proper name but ultimately it's microsoft's protocol like their version to authenticate on their nt systems i believe it was created back some years back back in the what 3.1 windows version which is years back right so either way it's specific for windows it's their version uh when it comes to um uh network authentication and because that it is more like you know in this case a good example would be like when dealing with corporations right uh when they didn't when you're dealing with a sharepoint on-prem a lot of that is you know um it's connected to the internal network which normally uses the your the windows nt login to be able to connect to it and so on so our config file will be slightly different so we'll go through that in a minute um so let me import that in now that i got that imported let's come down this sharepoint uh url we're not going to need the only one that we're going to need is going to be the sharepoint sites but not the url so i could actually delete this let's get that deleted we do need username password and then of course the site the site is going to be the the actual like the um the url like the main um the main url the sharepoint and then of course the site information again once we get to the config file i'll show you how that looks it will kind of compare to the sharepoint that i set up as well so we kind of do a comparison there um that's fine so this piece here strictly belongs to the again the sharepoint cloud version we don't need in our version so let's just comment it out for now but we are going to end up bringing in it's going to be this as you could tell it's asking for you their name and password so we're going to go ahead and pop that in username and password right which is these guys over here um let me call this oops credentials equals this right so i'm going to assign this here so these us cookies and version we don't need in this case so we're going to actually get that deleted now what we are going to do there is a parameter to call us and this is where we're going to end up passing in our credential object boom which again it's this guy up here so that's being brought in let me go ahead and delete this just kind of clean it up so here's the thing really that's that's it guys when it comes to the tweaks that we had to make from the the original product video that i made those are really the only changes we're doing you know we're removing the office 365 without importing that in um and then we got to import this in the http ntlms um that gets imported in that class and then of course this you know we set our credentials which is username password and then we pass that in in here so now that we have this set up which is this is it that those are the only changes we need to make um so if you're if you're working on the old source code these you know just make those few changes you should be good the next thing that we need to tweak and modify going to be is our config file so let's go ahead and go there i haven't entered my password yet you know so i kind of show y'all but the format is different under username we're not dealing with email address no more username it's actually going to be again in your company most likely with the way you log into your laptop or your pc or whatever is you know there's a domain which is the corporate domain this is the one that i created for testing on my vm and i called it i am loo two forward slashes and then it's going to be your username a lot of corporations use first initial last name or less initial first name or you know whatever it is that they use but whatever that username is or maybe it's a number right some company use just three five two one one seven again whatever that is you will enter that in and of course put in your password now this is remember we deleted this this url we don't need it in this case so that's gonna go now under sites this i want you to i want to compare how it needs to be set up this is pretty much the the you are the main url for your site right so a lot of corporations it could be something like um you know team you know software team dot um i don't know whatever the company name is dot com right or something like that it just all depends on how they have to set up but normally in order to figure that out go to sharepoint when you go to sharepoint you're gonna see it up here i don't have this again this is this sharepoint right now is only living within the the vm that i have uh but if i want to make it external and access it external like beyond the ip address right through an actual um domain then ultimately i would have to get that set up and you know it will be whatever name i call it dot com right maybe i'll call it i am lu youtube.com if i but again that's all different setup so whatever that is you're gonna you're gonna take and then on top of that um if you go into your site so let's say your company a lot of companies have multiple sites let's say you have 10 sharepoint sites and they just say the site that you're going into is called software team i don't know around you making it up that's what it's called well no most likely it's going to be the your your url sites and then it going to be whatever the name of your site is called right in my case i call it deliverment because that's how i caught it in my previous video try to keep it the same so whatever that is you're gonna you're gonna take that and then you're gonna put it in uh that this will be your site url pretty much it's the full site pass but what i want to want you to keep in mind is what not to do is do not copy everything do not copy the list do not copy the name of the list the all items dot aspx don't there's no need to do that right all we need is pretty much the the url the main url the sites the site name whatever that is then of course that's it you know that's all we need so just like the way i have it here right so now if i go back to sharepoint um because that's where we're bringing in and let me go to my project so again straightforward just like the other one right we're gonna get it i'm just gonna print it out for now i'm not gonna i mean you could do there's other stuff you could do with it right i think initially my previous video i extracted it and i saved it to excel you could do that you could save it to a database you could do you know pass that data to an api there's so much so many things you can do but but the main purpose here just to authenticate to be able to have the same results and you could take the source code if you want to export it to excel on the previous video to do so but here i do want to show you that hey a i'm able to authenticate to a sharepoint on-prem and then of course be able to get the results from my list so in the in this case this is what i should get back i should get back a list of mark street blah blah blah so let's go ahead and run it now so if i were to run this it would be python project let's run oh what happened oh i didn't pass my password uh no wonder all right so let me switch screens let me go ahead and put in my password right quick alright cool now that i put in my my credentials again my password let's run it again and as you can see we're getting back that list back right we get it back in a json format we have street city state postal what else do we have title which is mark so if i were to for example we let's go ahead and add a new one a new record in here we call this john smith from five main uh let's say four words um seven i don't know they're making up number texas let's save cool so now that we have that in there if i go back and we rerun it now we should see two two rows in here and we do here's street and then we will we will see streets where that right here uh street again for that other that new one so again it's it's a list right it's a list so in order to to extract the data you would iterate over it you know and um iterate over the list and then from there it's a json data pretty much right make it a dictionary just extract the key values and do whatever you choose to it but you know the the main purpose from here from this was more so just to see the connection of it right so hopefully this helps out again i got a fee request again shout out to will me and will met earlier in the week we kind of reviewed his code and we realized that um this code that the previous code that i that i made that i had did not work for him because it was built for office 365 and um so i did some testing and i i was able to again at least now able to make a video that relates to on-prem so hopefully it helps y'all out again give me a thumbs up give me a follow much appreciated man and thanks for watching the video peace
Info
Channel: I am Lu
Views: 8,491
Rating: undefined out of 5
Keywords:
Id: R_AoXJUgNM4
Channel Id: undefined
Length: 16min 41sec (1001 seconds)
Published: Sun Mar 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.