Wrox Programmer Forums
|
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2007, 05:47 AM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?







Similar Threads
Thread Thread Starter Forum Replies Last Post
SharePoint WSS 3.0/MOSS 2007 articles on Wrox.com jminatel SharePoint Development 3 February 28th, 2009 04:30 AM
Upgrading WSS 2.0 to MOSS ncastro SharePoint Admin 1 June 5th, 2008 08:13 PM
MOSS list and InfoPath Giannis Infopath 0 October 16th, 2007 07:31 AM
MOSS Search Error x_ray SharePoint Admin 3 August 31st, 2007 06:04 PM
MOSS TS kareemshaker BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 3 August 7th, 2007 11:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.