Questions tagged [directoryservices]

System.DirectoryServices is the .NET library used to access Microsoft's Active Directory, which holds information about users, groups, computers, permissions and more

System.DirectoryServices is the managed-code .NET library used to access Microsoft's Active Directory.

With .NET 3.5, an additional namespace System.DirectoryServices.AccountManagement makes all tasks related to users, groups, computers much easier, with strongly typed .NET classes representing those objects in Active Directory

773 questions
77
votes
5 answers

How to determine if user account is enabled or disabled

I am throwing together a quick C# win forms app to help resolve a repetitive clerical job. I have performed a search in AD for all user accounts and am adding them to a list view with check boxes. I would like to default the listviewitems' default…
Bryan
  • 3,224
  • 9
  • 41
  • 58
55
votes
14 answers

Error 0x80005000 and DirectoryServices

I'm trying to run a simple LDAP query using directory services in .Net. DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com"); directoryEntry.AuthenticationType = AuthenticationTypes.Secure; …
GodEater
  • 3,445
  • 2
  • 27
  • 30
49
votes
11 answers

How to get all the AD groups for a particular user?

I checked this post already. But it doesn't answer my question. I want to get all the active directory groups in which a particular user is a member. I've written the following code. But I'm not able to proceed further as I don't know how to give…
NLV
  • 21,141
  • 40
  • 118
  • 183
48
votes
7 answers

System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred

I have the same web app working in three others servers. Anyone have any idea why is not working in the 4th server? See the error and stacktrace: An operations error occurred. Description: An unhandled exception occurred during the execution of …
Vinicius Ottoni
  • 4,631
  • 9
  • 42
  • 64
47
votes
4 answers

Difference between PrincipalSearcher and DirectorySearcher

I see Active Directory examples that use PrincipalSearcher and other examples that do the same thing but use DirectorySearcher. What is the difference between these two examples? Example using PrincipalSearcher PrincipalContext context = new…
Drew Chapin
  • 7,779
  • 5
  • 58
  • 84
41
votes
7 answers

How to programmatically change Active Directory password

I have a set of test accounts that are going to be created but the accounts will be setup to require password change on the first login. I want to write a program in C# to go through the test accounts and change the passwords.
Jeff
  • 5,913
  • 2
  • 28
  • 30
37
votes
9 answers

System.DirectoryServices is not recognised in the namespace 'System'

I'm trying to use System.DirectoryServices in a web site project and I'm getting this error: The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?) My project has a…
jansokoly
  • 1,994
  • 2
  • 18
  • 25
27
votes
3 answers

How to get Active Directory Attributes not represented by the UserPrincipal class

What I mean is that right now I am using System.DirectoryServices.AccountManagement and if I use UserPrincipal class I only see the Name, Middle Name, etc so in my codes it like UserPrincipal myUser = new UserPrincipal(pc); myUser.Name =…
Mondyak
  • 395
  • 1
  • 5
  • 10
26
votes
5 answers

Memory Leak when using DirectorySearcher.FindAll()

I have a long running process that needs to do a lot of queries on Active Directory quite often. For this purpose I have been using the System.DirectoryServices namespace, using the DirectorySearcher and DirectoryEntry classes. I have noticed a…
Can Gencer
  • 8,822
  • 5
  • 33
  • 52
25
votes
10 answers

How do I loop through a PropertyCollection

Can anyone provide an example of how to loop through a System.DirectoryServices.PropertyCollection and output the property name and value? I am using C#. @JaredPar - The PropertyCollection does not have a Name/Value property. It does have a…
Michael Kniskern
  • 24,792
  • 68
  • 164
  • 231
24
votes
4 answers

How to determine all the groups a user belongs to (including nested groups) in ActiveDirectory and .NET 3.5

I have an application that uses ActiveDirecotry authorisation and it has been decided that it needs to support nested AD groups, e.g.: MAIN_AD_GROUP | |-> SUB_GROUP | |-> User So, the user in not directly a…
Sergi Papaseit
  • 15,999
  • 16
  • 67
  • 101
24
votes
3 answers

Create an application pool that uses .NET 4.0

I use the following code to create a app pool: var metabasePath = string.Format(@"IIS://{0}/W3SVC/AppPools", serverName); DirectoryEntry newpool; DirectoryEntry apppools = new DirectoryEntry(metabasePath); newpool =…
jgauffin
  • 99,844
  • 45
  • 235
  • 372
23
votes
1 answer

System.DirectoryServices.DirectorySearcher causing "Arithmetic operation resulted in overflow" errors

I'm getting the following intermittent errors related to querying AD using DirectorySearcher.FindOne() or FindAll(). System.OverflowException: Arithmetic operation resulted in an overflow. at…
Abhijeet Patel
  • 6,562
  • 8
  • 50
  • 93
22
votes
2 answers

UserPrincipal.GetGroups fails with unknown error

I am trying to get all Active Directory groups for a user, with the following code: private static IEnumerable GetGroupNames(string userName) { using (var context = new PrincipalContext(ContextType.Domain)) { …
Holstebroe
  • 4,993
  • 4
  • 29
  • 45
21
votes
9 answers

The type or namespace name 'DirectoryServices' does not exist in the namespace?

CS0234: The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?) This page was working fine,show records from directly services with no error. but now it gives the above…
Ali
  • 3,545
  • 11
  • 44
  • 63
1
2 3
51 52