Questions tagged [groupprincipal]

Encapsulates group accounts of Microsoft Directory Services.

Encapsulates group accounts of Directory Services. Group accounts can be arbitrary collections of principal objects or accounts created for administrative purposes.

It is part of the Microsoft .NET FrameWork 3.5+

23 questions
9
votes
1 answer

Do I really need to call Dispose() on every Principal?

I'm doing some Active Directory work with .NET's System.DirectoryServices.AccountManagement namespace. I noticed that Principal implements IDisposable, which causes sort of a headache since everything in that namespace inherits Principal. E.g.…
Hank
  • 8,289
  • 12
  • 47
  • 57
6
votes
2 answers

Extend UserPrincipal class

I do the extension of the UserPrincipal class to retrieve some missing properties that i need: [DirectoryObjectClass("user")] [DirectoryRdnPrefix("CN")] class UserPrincipalExt : UserPrincipal { public UserPrincipalExt(PrincipalContext context) …
4
votes
2 answers

GroupPrincipal throwing "System.Runtime.InteropServices.COMException (0x8007200A): The specified directory service attribute or value does not exist."

I'm using System.DirectoryServices.AccountManagement to query for a user and then find the groups for that user. var _principalContext = new PrincipalContext(ContextType.Domain, domainAddress, adContainer, adQueryAccount,…
Jim
  • 4,910
  • 4
  • 32
  • 50
4
votes
1 answer

GroupPrincipal Rename group

I'm trying to rename a group. My code looks like the following PrincipalContext context = new PrincipalContext(ContextType.Machine); GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "GroupName"); group.SamAccountName =…
Sam Stephenson
  • 5,200
  • 5
  • 27
  • 44
3
votes
1 answer

How to Get Current User Principal

I want to use Windows Authentication and get User info such as Givenname, Surname, etc. I used UserPrincipal.Current in IIS and I got an exception, but IIS express looks fine.
Jaider
  • 14,268
  • 5
  • 75
  • 82
2
votes
0 answers

UserPrincipal.IsMemberOf(GroupPrincipal) across domains ASP.Net

I am looking to amend a site to validate across domain but it gives the error below when run and login as the user from the other domain. Can you advise what security setting needs to be applied to the ASP.Net application pool to enable this? The…
2
votes
0 answers

While trying to resolve a cross-store reference, the SID of the target principal could not be resolved

I have a code sample like below PrincipalContext context = new PrincipalContext(ContextType.Domain, "aaaaa", "aaaa\\bbb", "pppppp"); var group = GroupPrincipal.FindByIdentity(context, IdentityType.Guid,…
Kunde Hong
  • 21
  • 1
  • 3
2
votes
1 answer

List local group members

I am trying to build a collection of all local groups and their respected members, however the challenge I am having with the listed code bellow is that "Administrators" group members is empty, all other groups on the server returns their members…
1
vote
1 answer

Why am I getting "No security object matching the specified parameters found" error (GroupPrincipal)

I'm creating a program that adds and removes domain users to/from local groups on a specific computer. I successfully finished part that adds users to group, but when it comes to removing I'm getting this error. Exception thrown:…
Tae
  • 11
  • 6
1
vote
0 answers

UserPrincipal.Current returns a GroupPrincipal (when ran towards a Azure AD created user) - however a UserPrincipal type is expected

I'm trying to retrieve the following information from a Azure AD managed user account using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using…
1
vote
0 answers

UserPrincipal.FindByIdentity Unable to cast object of type 'GroupPrincipal' to type 'UserPrincipal

Good morning, i'm trying to find a user in our active directory, but am getting the following exception: {System.SystemException} = {"Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type …
1
vote
1 answer

Check if a DirectoryEntry is the last of a Group in Active Directory C#

Hello, I need to check if a DirectoryEntry is the last one of a Group in AD. I don't know why, but my boss says he want a Messagebox. The method below is just a little part of my big project. What it does? I gets all users of a group in AD. Every…
user4628051
1
vote
0 answers

IIS connection to active directory for GroupPrincipal user.IsMemberOf

I have tested this in Visual Studio 2013 and it works fine, but after publishing to the web server, I get a 401 error. Here is the code, but I don't think its the issue. I think its the set up on the IIS server that I inherited, since it worked in…
1
vote
0 answers

Can not retrieve one particular group users in Active Directory using PrincipalContext

Getting exception system.directoryservices.accountmanagement.principaloperationexception : There is no such object on the server Trying to get all members of a group. Getting exception with one particular group only, able to get members of other…
1
vote
2 answers

GroupPrinciple.FindbyIdentity is too slow

I have created a function to add one user at a time into particular group (Administrators etc) but it seems to be taking too long to respond on GroupPrinciple(5-10 seconds) and group.members.add(5-10 seconds) call and slowing down my app, it takes…
user2229874
  • 79
  • 1
  • 9
1
2