0

We always used C# to query Active Directory, recently we need to add a patch to some code and it would be easier for us to query Active Directory straight from SQL DB as then we won't need to make any change to our code base other then stored procedures.

I got no clue how it would be seen in world of best practices, would it be considered a bad design move?

  • 2
    Never did it but sounds like very bad design to me. On the other hand, we know nothing about the specific requirement. Could you elaborate on what you are trying to achieve? – marstato Oct 12 '17 at 11:00
  • If your application is C#, it is new enough where the authors should have known better. Do not do it this way. – TheCatWhisperer Oct 12 '17 at 17:27
1

You can add .net class libraries to MSSQL. This will allow you to do anything that you can program. And you can definitely make a .net class lib that can query Active Directory

https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration/deploying-clr-database-objects

However! The only reason I can think of doing this is that you completely lack an application layer to your software and are doing everything in stored procs.

This is considered bad practice for many reasons, but most of all because code running on your SQL box slows down its primary function of being a database and makes it an expensive bottleneck to your entire operation.

Edit: As you updated I've thought of a second reason:

You have implemented change control on your source code, which means that if you change the source code you have some red tape to go through, perhaps versioning, testing and deployment. However, you have not implemented the same controls on your database and can update stored procs or data without having to do these things.

This is also bad practice, as you should implement the same change control for your database as you have with the rest of your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.