directoryservices

ActiveDirectory error 0x8000500c when traversing properties

狂风中的少年 提交于 2019-11-28 12:31:47
I got the following snippet ( SomeName / SomeDomain contains real values in my code) var entry = new DirectoryEntry("LDAP://CN=SomeName,OU=All Groups,dc=SomeDomain,dc=com"); foreach (object property in entry.Properties) { Console.WriteLine(property); } It prints OK for the first 21 properties, but then fail with: COMException {"Unknown error (0x8000500c)"} at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.PropertyEnumerator.get

How to register System.DirectoryServices for use in SQL CLR User Functions?

爷,独闯天下 提交于 2019-11-28 08:29:03
I am porting an old 3 2-bit COM component that was written in VB6 for the purpose of reading and writing to an Active Directory server. The new solution will be in C# and will use SQL CLR user functions. The assembly that I am trying to deploy to SQL Server contains a reference to System.DirectoryServices . The project does compile without any errors but I am unable to deploy the assembly to the SQL Server because of the following error: Error: Assembly 'system.directoryservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog. What are the

DirectoryServicesCOMException 80072020 From IIS 7.5 Site Running Under ApplicationPoolIdentity

萝らか妹 提交于 2019-11-28 07:54:19
问题 I'm having trouble hunting down an issue where an ASP.NET 4 application fails while trying to get user groups for a given user from time to time. The application pool associated with this application is setup to run under ApplicationPoolIdentity. Exception Info System.DirectoryServices.DirectoryServicesCOMException HRESULT: 80072020 Message: An operations error occurred. Extended Message: 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be

C# accessing active directory with different user credentials

北战南征 提交于 2019-11-28 03:50:38
问题 There is a new user creation application that we have just provided our users. However these users need the ability to creation users through the application even though they themselves do not have permission to create users. In C# how do you impersonate another user in order to have this functionality. This application primary using System.DirectoryServices . Code snippet: DirectoryEntry dEntry = new DirectoryEntry("LDAP://OU="); DirectorySearcher dSearcher = new DirectorySearcher(dEntry); /

Active Directory Services: PrincipalContext — What is the DN of a “container” object?

依然范特西╮ 提交于 2019-11-28 03:43:15
I'm currently trying to authenticate via Active Directory Services using the PrincipalContext class. I would like to have my application authenticate to the Domain using Sealed and SSL contexts. In order to do this, I have to use the following constructor of PrincipalContext (link to MSDN page) : public PrincipalContext( ContextType contextType, string name, string container, ContextOptions options ) Specifically, I'm using the constructor as so: PrincipalContext domainContext = new PrincipalContext( ContextType.Domain, domain, container, ContextOptions.Sealing | ContextOptions

System.DirectoryServices.DirectorySearcher causing “Arithmetic operation resulted in overflow” errors

不羁岁月 提交于 2019-11-27 23:29:02
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 System.DirectoryServices.SearchResultCollection.ResultsEnumerator.GetCurrentResult() at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.get_Current() at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.System.Collections.IEnumerator.get_Current() This is happening in a web app and seems to happen after the app has been running for several hours. This is a documented

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

走远了吗. 提交于 2019-11-27 20:31:33
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 = "aaaaaa"; myUser.SamAccountName = "aaaaaaa"; . . . . myUser.Save(); How would I see the attribute like mobile or info? Raymund The proper way of doing it is by using PrincipalExtensions where you extend the Principal you are after and use the methods ExtensionSet and ExtensionGet as explained here . In this case, you need to go one level deeper - back into the

Memory Leak when using DirectorySearcher.FindAll()

左心房为你撑大大i 提交于 2019-11-27 20:29:07
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 memory leak in the application. It can be reproduced with this code: while (true) { using (var de = new DirectoryEntry("LDAP://hostname", "user", "pass")) { using (var mySearcher = new DirectorySearcher(de)) { mySearcher.Filter = "(objectClass=domain)"; using (SearchResultCollection src = mySearcher.FindAll()) { } } } } The documentation for these

How to determine if user account is enabled or disabled

妖精的绣舞 提交于 2019-11-27 17:40:19
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 check state to depend upon the enabled/disabled state of the account. string path = "LDAP://dc=example,dc=local"; DirectoryEntry directoryRoot = new DirectoryEntry(path); DirectorySearcher searcher = new DirectorySearcher(directoryRoot, "(&(objectClass=User)(objectCategory=Person))"); SearchResultCollection results = searcher.FindAll(); foreach

Determine if user is in AD group for .NET 4.0 application

笑着哭i 提交于 2019-11-27 14:05:25
问题 I am trying to determine if a user is a member of an Active Directory (AD) group for an internal ASP.NET 4.0 application. The code below throws an "Attempted to access an unloaded appdomain" exception error on the last line (return statement) in the case when the user is not a member of the AD group. public static bool IsInADGroup(string userName, string groupName) { var principalContext = new PrincipalContext(ContextType.Domain); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity