Search

Unknown PrincipalOperationException when add UserPrincipal in collection GroupPrincipal.Members by DE-Soft

Closed
as Duplicate Help for as Duplicate

4
0
Sign in
to vote
Type: Bug
ID: 610995
Opened: 10/6/2010 3:34:35 AM
Access Restriction: Public
2
Workaround(s)
5
User(s) can reproduce this bug
The operation GroupPrincipal.Members.Add(UserPrincipal) raise unknown Exception 0x80005000 in Net 4.0-Source System.DirectoryServices.AccountManagement.
- ActiveDirectory: Windows 2003 Domain on Windows Server 2003 R2,
- Application on Domainclients: Windows XP Prof SP3 or Windows 7 Prof,
- All systems full patched via WSUS 3.0 SP2 with complet Framework to NET 4.
Application as 3.5-Framework run posible.

thx Daniel
Details (expand)

Visual Studio/Silverlight/Tooling version

.NET Framework 4

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

        private bool AddAdmin(string Name, string Container, string Admin, string AdminPw)
        {
            try
            {
                using (PrincipalContext _PC = new PrincipalContext(ContextType.Domain, null, Container, Admin, AdminPw))
                {
                    UserPrincipal _UP = UserPrincipal.FindByIdentity(_PC, Name);
                    if (_UP == null) return false;
                    SecurityIdentifier _Sid = new SecurityIdentifier(WellKnownSidType.AccountDomainAdminsSid, _UP.Sid.AccountDomainSid);
                    GroupPrincipal _GP = GroupPrincipal.FindByIdentity(_PC, IdentityType.Sid, _Sid.Value);
                    if (_GP == null) return false;
                    _GP.Members.Add(_UP);
                    _GP.Save();
                    return true;
                }
            }
            catch { return false; }
        }

Product Language

German

Operating System

Windows 7

Operating System Language

German

Actual results

Message=Unbekannter Fehler (0x80005000)
Source=System.DirectoryServices.AccountManagement
ErrorCode=-2147463168
StackTrace:
     bei System.DirectoryServices.AccountManagement.ADStoreCtx.IsMemberOfInStore(GroupPrincipal g, Principal p)
     bei System.DirectoryServices.AccountManagement.PrincipalCollection.Add(Principal principal)
     bei DeSoft.Admi.Management.AdmiProvider.TaObjAuthorize(String Name) in D:\Visual Studio 2010\Projects\DeAdmiConnector\DeAdmiConnector\DeSoft.Admi.Management.cs:Zeile 416.
InnerException: System.Runtime.InteropServices.COMException
     Message=Unbekannter Fehler (0x80005000)
     Source=System.DirectoryServices
     ErrorCode=-2147463168
     StackTrace:
            bei System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
            bei System.DirectoryServices.DirectoryEntry.Bind()
            bei System.DirectoryServices.DirectoryEntry.get_AdsObject()
            bei System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
            bei System.DirectoryServices.DirectorySearcher.FindOne()
            bei System.DirectoryServices.AccountManagement.ADStoreCtx.IsMemberOfInStore(GroupPrincipal g, Principal p)
     InnerException:

Expected results

Add specified user into Group Domain-Admins without Exception. :)
File Attachments
0 attachments
Sign in to post a comment.
Posted by DE-Soft on 9/11/2012 at 10:12 AM
Repeat, where is the link to the duplicate? Problem is not fixed in NET 4.0!!!

Grmpf. Dani
Posted by JTokach on 8/26/2011 at 1:32 PM
Repeat, where is the link to the duplicate? Has this been fixed? Running VS2010.
Posted by SimonCropp on 2/2/2011 at 4:44 PM
Where is the link to the duplicate
Posted by david-ptbc on 1/4/2011 at 1:46 PM
What is the status of this??
This says "Resolved As Duplicate" -- so where is the duplicate that has the fix instead of the work around??
Posted by Microsoft on 1/4/2011 at 11:57 AM
Thank you for your feedback comments! We were able to repro the issue and will be looking to fix this issue in a future release. If this issue is urgent, please contact support directly(http://support.microsoft.com).
Posted by Microsoft on 10/6/2010 at 10:46 PM
Thank you for reporting the issue.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.These specialized experts will follow-up with your issue.
Posted by Microsoft on 10/6/2010 at 4:21 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by SourStones on 1/5/2012 at 4:06 PM
Thank you so much. *ThumbsUp*
Posted by SimonCropp on 11/22/2010 at 7:08 PM
instead of using

groupPrincipal.Members.Add(memberPrincipal);
groupPrincipal.Save();

use
using (var groupDirectoryEntry = (DirectoryEntry)groupPrincipal.GetUnderlyingObject())
{
    groupDirectoryEntry.Properties["member"].Add(memberPrincipal.DistinguishedName);
    groupDirectoryEntry.CommitChanges();
}