Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 4th, 2007, 05:47 AM
Authorized User
 
Join Date: Jun 2007
Location: , , .
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?


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.