directoryservices

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

╄→尐↘猪︶ㄣ 提交于 2019-11-26 21:28:16
问题 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

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

天涯浪子 提交于 2019-11-26 20:23: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? 回答1: The proper way of doing it is by using PrincipalExtensions where you extend the Principal you are after and use the methods

How to determine if user account is enabled or disabled

你。 提交于 2019-11-26 19:05:18
问题 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, "(&

Set callback for System.DirectoryServices.DirectoryEntry to handle self-signed SSL certificate?

我的梦境 提交于 2019-11-26 17:49:52
问题 I have an application replicating data from a directory service using typical System.DirectoryServices.DirectoryEntry code. I now have a requirement to replicate from Novell eDirectory using SSL with a self-signed certificate. I suspect that the existing code would work with a valid certificate that could be verified, or perhaps if the self-signed cert is added to the local machine keystore. In order to make it work for sure with a self-signed cert however, the only solution I can find is to

Connecting to LDAP from C# using DirectoryServices

梦想与她 提交于 2019-11-26 16:08:51
问题 I am trying to connect to an edirectory 8.8 server running LDAP. How would I go about doing that in .Net? Can I still use the classes in System.DirectoryService such as DirectoryEntry and DirectorySearcher or are they AD specific? Do I need to specify the "Connection String" any differently? I am trying something like the code below but it doesn't seem to work... DirectoryEntry de = new DirectoryEntry ("LDAP://novellBox.sample.com","admin","password",AuthenticationTypes.None);

Error 0x80005000 and DirectoryServices

我们两清 提交于 2019-11-26 13:29:15
问题 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; DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry); directorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName={0}))", username); var result = directorySearcher.FindOne(); var