You are hereProgramming & Web Design


Programming & Web Design


Programming & Web Design

VB.Net - How to Disable a Domain Account in Active Directory

By hagrin - Posted on 10 February 2007

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):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

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

Visual Basic .Net Coding Samples

By hagrin - Posted on 10 February 2007

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

C#.Net - How to Unlock a Domain Account in Active Directory

By hagrin - Posted on 10 February 2007

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):

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.DirectoryServices;

...

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();
}

C#.Net - How to Disable a Domain Account in Active Directory

By hagrin - Posted on 10 February 2007

How to Disable 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):

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.DirectoryServices;

...

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["userAccountControl"].Value = 0x0002;
usr.CommitChanges();
}

SharePoint v3: Turn On Friendly Error Messages

By hagrin - Posted on 08 February 2007

Anyone who has worked with SharePoint extensively knows that when troubleshooting SharePoint errors you will be confornted with some of the most meaningless, generic error messages of any major application around. However, thanks to articles like this (which is where I first read this tip), SharePoint developers and administrators can turn on more descriptive, "friendly" error messages by making two changes to your web applications web.config file -

  1. Set customErrors=off
  2. Set CallStack="true"

Making these two changes in your development environment will really help your SharePoint developers and admins troubleshoot technical issues.

SharePoint v3: Recreating the Quick Launch Menu

By hagrin - Posted on 07 February 2007

UPDATE: 2009 June 17th - Please see the comment by David in the comments section. His fix is the best fix I have seen for this problem.

If you see any improvements that I can make, let me know by leaving me a comment. Hope this helps someone.

Versioning

  1. Version 1.2 - (2009 June 17) - Much better solution posted in comments by user David.
  2. Version 1.1 - (2007 May 2) - Bug fixes which include:
    • Applying Quick Launch logic that is used in the SharePoint WSS 40 Free Application templates.
    • Wrapping data retreived from the database and other sources in System.Web.HttpUtility.UrlPathEncode() to prepare for URL formation and usage.
    • Colorized the comments (I'm looking for a Drupal module to automatically do this for me)
  3. Version 1.0 - (2007 Feb 7) - Original Article on recreating the SharePoint v3 Quick Launch through a Web Part

Microsoft Releases Live Search SOAP API 1.0

By hagrin - Posted on 06 February 2007

Microsoft announced their Live Search SOAP API 1.0 is out of beta and has been rebranded to reflect the name of their search engine. The Live Search SOAP API excites programmers like me because, while Google has removed any future access to their SOAP API, Microsoft is enhancing theirs and providing more power to the programmers of the world. A quick comparison of the Google SOAP API and the Live Search SOAP API shows the following:

  • The Live Search SOAP API is still being actively developed by Microsoft while Google has stopped releasing SOAP API keys and support to the servers handling the API requests.
  • The Google SOAP API allows for 1,000 queries per day where the Live Search SOAP API allows for up to 10,000 queries per day. The higher number of maximum daily queries would allow for companies to more accurately track their performance and track more keywords and phrases.
  • The Google SOAP API allows you to only pull the first 100 results for a particular search phrase while the Live Search SOAP API can return up to the first 1,000 results for a term.

In addition to the comparison with Google, the Live Search SOAP API has added features such as additional language support, enhancing search tag results, improving local search, phone book results and improved their documentation with additional code samples. Remember, you will Visual Studio 2005 and the .Net 2.0 Framework to utilize this API.

The only problem I see with the new Live Search SOAP API? It can't query the Google index.

C# .Net Coding Samples

By hagrin - Posted on 30 January 2007

Below are code samples utilizing C# .Net. If you have any questions, comments or corrections on any code sample, please email me at "hagrin at gmail dot com" (email written out to avoid email harvesters) and I'll try and get back to all user inquiries as soon as possible. Thank you and hopefully this code will prove to be helpful.

Disable a Domain Account in Active Directory
Unlock a Domain Account in Active Directory

Web 2.0 Design Guide

By hagrin - Posted on 22 December 2006

Although I believe that each website should have its own individualistic design and feel, having well-written guides for inspiration and to see what the rest of the industry seems to find attractive (on the whole) can often be useful. One of the best Web 2.0 design guides that I have read in a long time was produced by the owners of Web Design from Scratch.

What makes this design guide better than all the rest is its in-depthness, layout, information given, topics covered and clear presentation. First, the entire article, which is very detailed, is presented on a single page. This can't be understated since there has been an increase in websites attempting to increase advertising revenue and clickthroughs by taking a guide/review and splitting it up into several pages so more ads and pageviews can be counted. Next, a clear and simple Table of Contents exists at the top of the article for navigational ease again adding to the terrific presentation.

Most importantly is the content provided. The presentation concepts for the nebulous term of Web 2.0 are captured pretty concisely and backed up with examples that don't all just look the same. Icons, gradients, fonts, color schemes and other Web 2.0 "concepts" are not only explained, but the reader is also given a few contrasting examples to see different ways that a technique can be implemented. Definitely check this guide out to spur some design ideas.

Google Ends Support for SOAP Search API

By hagrin - Posted on 19 December 2006

Well, this news puts the lockdown to the SEO project I was working on.

Google has very quietly ended support for the SOAP Search API which allowed SEOs like myself to query the search engine through a SOAP call and take those results and build reports for those looking to measure their site's performance within the search engine. Now, the results from the search engine definitely weren't accurate as manual searches for terms displayed much different results than the SOAP generated results. However, it still provided a valuable tool to SEOs to paint a broad picture of their site's performance.

No more SOAP API keys are being issued and it is unclear as to when the SOAP server will be taken offline rendering all these SOAP driven applications useless.

Google is now directing their coders to the AJAX Search API which is more restrictive than the previous SOAP API. However, now Google requires that a valid URL send the request to the Google server and you can no longer run background processes to gather these results. This means an end to the SEO report generator as we know it and a switch to "illegal" page scraping will most likely occur. I'll reserve judgement on all of this until I fully explore the alternatives, but I definitely see this as an unnecessary restriction that just encourages the more intensive page scraping.

Recent comments