Today, I started working on an application to perform bulk changes to our Deltek Vision database to change tasks, sub-tasks, budgets and billing terms. So, as I go to write the SQL connection string, something I have done 100s of times, I kept getting the following error from my app:
While the error is pretty descriptive, there is one slight problem - I'm not trying to access a 2005 SQL Server, but a SQL Server 2000 box. So, I do what any good programmer does - he searches the major search engines for a solution, but most of the examples are of users trying to 1) build a Web application and have a web.config error or 2) are actually trying to access a SQL Server 2005 database. Yikes, now what?
I can't stress this enough - check your connection string. I was actually passing a blank Data Source (I was using SelectedValue as opposed to SelectedItem) and since I have SQLExpress running on my development machine, I assume that's why I was generating a 2005 error when trying, in theory, to connect to a SQL 2000 machine. The lesson is - verify your connection string when getting this error and trying to access a SQL 2000 machine. If you're trying to access a SQL 2005 machine, follow the enabling remote connections info that you'll find on the hundreds of pages that come up in he search engines for this error.
When you're writing a development related blog, you're eventually (hopefully) going to write some code snippets that you want to share with your readers. However, in order to get the most out of that code snippet, you should make it easy to read and color coded so that potential users can quickly read through your code and evaluate its worth.
That's where CopySourceAsHTML will solve all your problems. CSAH is a plug-in that integrates directly into your Visual Studio IDE environment and allows you to highlight code, right click and choose "Copy As HTML". The tool is freeware and performs exceptionally - if you maintain a .Net developer blog, I would suggest installing this add-on.
Just a FYI to the 3 of you reading this site (Hi Mom and Dad!), I made an update to the Recreating the SharePoint Quick Launch story I posted back in February. I made some code fixes that were mainly introduced with the release of the 40 Free WSS Application Templates made by Microsoft.
Hope the bug fixes help!
Today, as I was converting some web applications from .Net 1.1 to .Net 2.0 I received the following error on the source pages of most of my ASPX pages -
Huh? That's what I said. However, the fix is relatively easy. What the error message is saying is that you probably have some element in your HTML code/script that has a value of "ID=Header". By giving this element a new ID name, the error message will be resolved.
When working with SharePoint v3 list data, it's important to understand the data structure used to store list items. List data is stored in the AllUserData table and the name should be your first indication that you might run into a problem if trying to pull or manipulate data stored in this table. Why? Well, "all" user data is stored in that table including deleted data and you will need to know how to filter out deleted items and that is where the tp_DeleteTransactionID column comes into focus.
The tp_DeleteTransactionID column is a varbinary field so you cannot readily read the contents of that column in SQL Server Enterprise Manager. This coulmn acts as a "deleted flag" and you will need to be able to know what items you have removed from your list, but you forgot to remove from your Recycle Bin. List items that you delete from your list, but that remain in your Recycle Bin will have the value of the tp_DeleteTransactionID column updated from the default value of 0x. Once you remove the items from your Recycle Bin, the item's corresponding rows will be deleted from the AllUserData, but until you do so those item's rows will remain in the AllUserData table.
So, if you want to filter out deleted content for the purpose of data manipulation or transformation, but you don't want to have to worry that the user has remembered to empty the Recycle Bin, add the following WHERE clause to your SQL statements -
Notice, that the value 0x is not surrounded by value defining apostrophes since the value is not a true string, numeric, date, etc. value, but a hex representation for the varbinary field.
Today, I encountered an error that I wasn't immediately sure how to fix while creating a new web part. After uploading the .DWP file to the web part gallery, I attempted to add the web part to a recently created web part page. Even though I had a Try/Catch/Finally wrapper around my code, I received a browser alert that had the following error:
After a very quick search for that error on Google's main search index and Google Groups, I found zero results. Then, I remembered that I didn't make the necessary corrections to the .DWP file - in particular, I left the Assembly field blank. After adding the correct assembly name, I saved the file, deleted the previously uploaded DWP file, re-uploaded the new DWP file and was able to successfuly add the web part. Success!
How to Unlock a Domain Account in Active Directory utilizing Visual Basic .Net - (note: you must have Domain Admin privledges to execute this code successfully and you must import the System.DirectoryServices namespace):
Dim strError As String
Try
Dim child As New System.DirectoryServices.DirectoryEntry("LDAP://DC=YourDomainsName,DC=com")
Dim searcher As New DirectorySearcher(child)
Dim result As SearchResult
Dim userEntry As DirectoryEntry
searcher.Filter = "(SAMAccountName=TheUsernameYouWantDisabled)"
searcher.CacheResults = False
result = searcher.FindOne
userEntry = result.GetDirectoryEntry
With userEntry
userEntry.Properties("LockOutTime").Value = 0
End With
userEntry.CommitChanges()
Catch ex As Exception
strError = ex.ToString
End Try
End Sub
How to Disable a Domain Account in Active Directory utilizing Visual Basic .Net - (note: you must have Domain Admin privledges to execute this code successfully and you must import the System.DirectoryServices namespace):
Dim strError As String
Try
Dim child As New System.DirectoryServices.DirectoryEntry("LDAP://DC=YourDomainsName,DC=com")
Dim searcher As New DirectorySearcher(child)
Dim result As SearchResult
Dim userEntry As DirectoryEntry
searcher.Filter = "(SAMAccountName=TheUsernameYouWantDisabled)"
searcher.CacheResults = False
result = searcher.FindOne
userEntry = result.GetDirectoryEntry
With userEntry
userEntry.NativeObject.accountdisabled = True
End With
userEntry.CommitChanges()
Catch ex As Exception
strError = ex.ToString
End Try
End Sub
Below are code samples utilizing Visual Basic .Net. If you have any questions, comments or corrections on any code sample, please email me at hagrin at gmail dot com and I'll try and get back to all user inquiries as soon as possible. Thank you and hopefully this code will proove to be helpful.
Disable a Domain Account in Active Directory
Unlock a Domain Account in Active Directory
How to Unlock a Domain Account in Active Directory utilizing C# .Net - (note: you must have Domain Admin privledges to execute this code successfully and you must import the System.DirectoryServices namespace):
...
private void btnDisableUser_Click(object sender, System.EventArgs e)
{
string strUserName = "InsertUserNameHere";
DirectoryEntry usr = new DirectoryEntry("LDAP://dc=InsertDomainHere, dc=COM");
DirectorySearcher searcher = new DirectorySearcher(usr);
searcher.Filter = "(SAMAccountName=" + strUserName + ")";
searcher.CacheResults = false;
SearchResult result = searcher.FindOne();
usr = result.GetDirectoryEntry();
usr.Properties["LockOutTime"].Value = 0x0000;
usr.CommitChanges();
}
Recent Comments
1 week 21 hours ago
1 year 6 weeks ago
1 year 6 weeks ago
1 year 8 weeks ago
1 year 8 weeks ago
1 year 11 weeks ago
1 year 12 weeks ago
1 year 12 weeks ago
1 year 13 weeks ago
1 year 13 weeks ago