Need help in MOSS 2007
Hi,
I am currently working as MOSS developer.
Now am developing a intranet site,in that i developing business functionality as application pages. In home page(sharepoint site collection) custom webpart i am tracking employee supervisor in active directory account by using LDAP path(system.directoryservice namespace),but when i am put webpart(deployed in GAC) into home page i got error "The authentication mechanism is unknown.
"
EXCEPTION DETAILS
System.Runtime.InteropServices.COMException: The authentication mechanism is unknown.
CODING
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.DirectoryServices;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace RetSuperVisor
{
public class ReturnUser
{
public string GetProperty(SearchResult searchResult, string PropertyName)
{
if (searchResult.Properties.Contains(PropertyName))
{
return searchResult.Properties[PropertyName][0].ToString();
}
else
{
return string.Empty;
}
}
public string ValidateUser(string username)
{
DirectoryEntry de = new DirectoryEntry("LDAP://MYDOMAIN", "username", "pwd",AuthenticationTypes.Secure);
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user)(SAMAccountName=" + username + "))";
deSearch.SearchScope = SearchScope.Subtree;
string[] arUser = new string[100];
foreach (SearchResult results in deSearch.FindAll())
{
arUser[0] = GetProperty(results, "manager");
}
string user = "";
int chk = 0;
int chk1 = 0;
for (int i = 0; i < arUser[0].Length; i++)
{
if (arUser[0].Substring(i, 1).ToString() == @"=")
{
chk = 1;
}
if (chk == 1 && chk1 == 0 && arUser[0].Substring(i, 1).ToString() != @"=")
{
if (arUser[0].Substring(i, 1).ToString() != @",")
{
user = user + arUser[0].Substring(i, 1).ToString();
}
else
{
chk1 = 1;
break;
}
}
}
deSearch.Filter = "(&(objectClass=user)(cn=" + user + "))";
deSearch.SearchScope = SearchScope.Subtree;
string[] arSupUser = new string[100];
string supuser= "";
foreach (SearchResult results1 in deSearch.FindAll())
{
arSupUser[0] = GetProperty(results1, "userPrincipalName");
}
for (int i = 0; i < arSupUser[0].Length; i++)
{
if (arSupUser[0].Substring(i, 1).ToString() != @"@")
{
supuser = supuser + arSupUser[0].Substring(i, 1).ToString();
}
else
{
break;
}
}
return supuser;
}
}
}
anyone can help in this?
|