Getting updated data from Active Directory? - c#

I have an app with a User table that was populated by an export from the Active Directory user list. Every couple of weeks the users send me another spreadsheet with the latest AD user list, and I have to update our User table with my own magic involving manipulating Excel and matching up usernames to know whether to insert or update.
I think it's time to automate this whole task. The easy way would be to have a scheduled task that polls AD every so often and updates all user information. But that might be a bit of a waste, since 99% of the time nothing will have changed between polls. One answer might be if there's a LastUpdated field anywhere in the AD user list, so I can know whether my information for any given user is up to date. Is there?
If not, is there any way of subscribing to some kind of push notification from AD, so that I don't have to keep checking, but when a user is inserted, updated or deleted, my app will get notified?

There is a way for push notification (LDAP change notification control) but it is restricted to monitoring a single object or the immediate children of a container. Besides, it may greatly affect performance of server.
Instead you may pick the pull mechanism: DirSync or USNChanged.
I am using DirSync in my project and it's working fine.
For details:
http://msdn.microsoft.com/en-us/library/ms677625(v=vs.85).aspx

Related

Is a Database Needed Behind My ASP Site

I am building a website Asp.Net/C# and one component has a schedule with the AJAX Calendar Extender that puts the selected date in a text box, of course. I also have an AJAX Time Picker pick a time in another box.
However, I'm feeling a little ambitious; I want it where if someone selects say... July 25th, 2014, at like 1:30 PM, I want it to throw back a message on selection that the block of time is already selected. The time intervals run every 15 mins apart (i.e., 1:00, 1:15, 1:30, and 1:45).
I'm thinking I need a database behind the site to hold this, maybe SQL Server or would a lightweight Access workup due? My though is that it will hit the database and check for a duplicate instance of the select date and time slot, chosen by the user - then report back if it gets a hit... otherwise, it will populate the date and time text fields in the form.
It's for a small yard service company that makes out calls, but I wanna test and push myself. Any advice and structure suggestions from some seasoned pros who would be greatly appreciated. Thanks. Let me know if I need to provide more details.
If you do not have a database holding the data, where will you store the booked time slot? Where you plan to store your login information like user acc/password.
Of course you can store into text file but I would suggest a light DB like access. It would be enough for you to store few tables with not many line of data.
I do not see any problem with your taught to verify the data again what you stored in db. It should be the way.

Get database record automatically at a specific time

I have a task that basically I don't know how to accomplish it and I want some advice from you guys : I have a database that contains many binary images and a website that has a button.
When I press it a select statement is executed to search all the newly inserted rows after a specific date and send it to the website to process. My boss asked me if there is any way I can do that process manually by using a web service or anything else like a trigger in the database that automatically searches for new rows after a specific date and sends the new rows to the web site.
I don't know if I explained what I need. My main question is it possible to do this and what is the best way to achieve it. one more thing if it is achievable can I trigger it to work every day at a specific time ? Thank you
As I understood you question, these are the requirements:
You need to automate the process that is now manually triggered by clicking the button on the web page
The simplest way to do this in my opinion would be to create a small Console application and install it on a suitable server. Then on the server create a Windows task scheduler (Google it unless you're already familiar with it) task that runs the console application on a suitable schedule.
You could for instance have it run once every night at say 10 minutes past midnight and it would fetch all images from the past day and "send them to be processed".
First of all you have to understand website is not a repository of records but it works based on user requests. So in your website if you want to change contents on web pages, try AJAX reqeusts. If you are looking for some options to update details in other systems periodically think of eitehr Windows services, or cron jobs or may be SSIS jobs etc.
Use Cursor and Trigger but u have to store date in database which u want display on particular date

How to track if user entered/changed something in WinForms GUI to warn user if there are unsaved changes?

I have a simple WinForms GUI with multiple TextBoxes, CheckBoxes, and RadioButtons for the user to enter / modify data. Everything is loaded / saved from a SQL Server database. How do I warn the user when he wants to close the GUI? Do I query SQL to get data and compare it with what is in the GUI and if there are any differences I simply warn the user? Or is there a better way? Also it's possible that during that time the user had a window open someone came in and changed something from another computer and the SQL Data would be different than what was orginally loaded into WinForms.
Regarding local changes:
Keep a local flag that you set to true on any changes for a general message.
You could have a dictionary if you want to keep track of specific changes.
To prevent other users from overwriting the data, you could use locking, and prevent others from opening that record, or only allow them to open in read only.
You can use a time stamp on that record, and check if it has changed since you last read it, then warn the user that the data is no longer the same.

Not sure how to store some data

I'm making a website that lets you share your music tastes, it works with a desktop client that monitors your media player (iTunes, whatever), and sends the details of the song that is currently playing to the site, where it is associated with your profile.
This output is displayed on your profile, and the idea is the page mirrors your local music player, right down the the position of a progress bar.
However I can't decide how to store the data. As soon as the song is over, it becomes useless, so something permanent like a MySQL database seems pointless.
Session variables don't work, because the script that does the work is not directing you to the page that displays the output. The idea is that the backend script just gets the info as it arrives and saves it somewhere, and you can get the latest info whenever you load the profile page.
I'm currently using a textfile, as a bad and temporary solution, just writing a new line each time and then reading it.
What is there between session variables and SQL?
And how can I get the output page to update every time there is new data? I need a way of storing it that allows events to be triggered, so checking it mustn't be too intensive.
I think a (My)SQL database would be alright, especially if you want to show the last few songs somebody played.
But if you just need a temporary data store to hold a single song per user, you could use a key-value store like memcached. It stores data directly in memory instead of a file or database. The key would be something unique (like the user's name or id) and the value would be data about the currently playing song.
You should look into memcached with a low cache expiry on keys of this type.
I would definitely store this in a database with a timestamp. For your display query, all you have to do is select the most recent (unless it has been more than a certain amount of time, in case the player is disconnected).
It might be best to hang on to this data. You may want it later to show which songs they play most or something. Otherwise, you can always delete the old records. I suspect keeping them will be worthwhile later. (Also consider the privacy implications of this. Make sure you tell your users the kind of data you keep in your privacy policy.)
Well I think you could use SQL, just have a table that stores the UserId, "current/last" song field, "currentlyPlaying" (bool), and you keep writting on top of that field everytime there is a new song, so that way you only have one row for each user all the time. It is still permanent, but you only keep track of the last song.
As a sidenote, you might want to save in a more permanently way all the songs a user plays.. if it is supposed to be a music tastes sharing site, having a history of played songs would let you make some nice algorithms like recommendations, etc.

Setting up user permissions for reading and writing document files in IIS7

I want to make a very simple CMS for my sites. So what I am thinking is this a user logs in and a list of their pages shows up. Now they change their ends and save it. My C# code would then write over the file/section.
So I don't think it would be to bad to do this however I am not sure about how it works with read and write premission and how to set it up.
Like I want the user to only be able to read and write to their files they own.
So if User A has Page1.html and Page2.html they can only read those files and write to those files they can touch User B's page3.html and Page4.html
So how would I setup this up?
Thanks
When you create your list of files, you will be reading that list from a database repository. Include in that code conditions that allow only those records for which the user has permission.
The most straightforward way to do this is to create a table with two columns: UserID and DocumentID. A presence of a record in the table indicates that the user has permission to that particular document. Add records to this table that give the user permissions to the appropriate documents.
Then, when you read the documents from the database, you can join this table to the documents table via the DocumentID, and filter the table by UserID. This will return only those records for which the user has permission. You can then use that set of records as the basis for the list of documents that you display to the user.
You could employ a cms the SharePoint way. You begin with a base file on the network. If a change to it is made then the page is stored in a database. each subsequent change is a db change and the application renders the last entry in the table for that page.
this does two things. first, you can see revisions and re-instate them. you can see a complete history of the page, who made the changes and when.
it also allows you to lock pages within the database and assign roles/users against the pages. you can then apply a decoration to the controller which checks rights and either renders the page or displays a access denied page and then log the attempted access to the page.
i know this sounds complex but can you foresee a time when after you've gone live with your cms that the client is going to want more from it? you need to implement a solution that's adaptable to needs.
if it's worth writing then it's worth writing well.

Categories

Resources