This commit is contained in:
Virtuworks 2013-02-06 18:19:48 -05:00
commit 5ee5167da9
7 changed files with 689 additions and 478 deletions

View file

@ -754,6 +754,49 @@ namespace WebsitePanel.Providers.HostedSolution
public bool DoesSamAccountNameExist(string accountName)
{
return DoesSamAccountNameExistInternal(accountName);
}
private bool DoesSamAccountNameExistInternal(string accountName)
{
HostedSolutionLog.LogStart("DoesSamAccountNameExistInternal");
HostedSolutionLog.DebugInfo("sAMAccountName : {0}", accountName);
bool bFound = false;
try
{
string path = GetRootOU();
HostedSolutionLog.DebugInfo("Search path : {0}", path);
DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.PropertiesToLoad.Add("sAMAccountName");
searcher.Filter = "(sAMAccountName=" + accountName + ")";
searcher.SearchScope = SearchScope.Subtree;
SearchResult resCollection = searcher.FindOne();
if (resCollection != null)
{
if (resCollection.Properties["samaccountname"] != null)
bFound = true;
}
}
catch (Exception e)
{
HostedSolutionLog.DebugInfo("Failed : {0}", e.Message);
}
HostedSolutionLog.DebugInfo("DoesSamAccountNameExistInternal Result: {0}", bFound);
HostedSolutionLog.LogEnd("DoesSamAccountNameExistInternal");
return bFound;
}
#endregion
#region Domains