Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
|
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 13th, 2007, 09:07 AM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Needed help in Sharepoint.

Hi,

I have inherited a sharepoint web part from dotnet Asp.net 2.0 that is
displaying task list in MOSS site. It calls FindAll() to locate a specific security
group, and then enumerates through the group to retrieve the user's
display names.

*Very* intermittently this web part will throw an exception - either
"System.Runtime.InteropServices.COMException: The server is not operational" or,
 sometimes, "The authentication mechanism is
unknown". When I say intermittently, I mean very intermittently - it is
fine 60% of the time. There doesn't seem to be any pattern to the
errors .
I am really hoping someone can help, this is proving very difficult to
fix as it is so irregular.


Code

 private DirectorySearcher GetDirectoryObject()
        {
            DirectoryEntry oDE = new DirectoryEntry("LDAP://MYDOMAIN", "username", "pwd", AuthenticationTypes.Secure);
            DirectorySearcher deSearch = new DirectorySearcher();
            deSearch.SearchRoot = oDE;
            return deSearch;
        }

        public string GetProperty(SearchResult searchResult, string PropertyName)
        {
            if (searchResult.Properties.Contains(PropertyName))
            {
                return searchResult.Properties[PropertyName][0].ToString();
            }
            else
            {
                return string.Empty;
            }
        }


        public string GetDept(string username)
        {

            DirectorySearcher deSearch = GetDirectoryObject();
            deSearch.Filter = "(&(objectClass=user)(SAMAccountName=" + username + "))";
            deSearch.SearchScope = SearchScope.Subtree;
            string UserDept = "";
            foreach (SearchResult results in deSearch.FindAll())
            {
                UserDept = GetProperty(results, "userPrincipalName");

            }

            return UserDept;
        }






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharepoint ramamurthi_c SharePoint Development 1 December 11th, 2009 07:01 PM
Need help getting started - Sharepoint ender165 BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 2 May 14th, 2008 12:53 PM
Sharepoint Jayarajmrj SQL Server 2000 1 July 30th, 2007 10:16 PM
WinForm and Sharepoint natarajan_ve .NET Web Services 0 July 28th, 2005 05:35 AM





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