directoryservices

Connecting to LDAP from C# using DirectoryServices

蓝咒 提交于 2019-11-27 12:53:46
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); DirectorySearcher ds = new DirectorySearcher(de); var test = ds.FindAll(); Any ideas? marc_s Well, I think your

Error 0x80005000 and DirectoryServices

风流意气都作罢 提交于 2019-11-27 12:19:06
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 resultDirectoryEntry = result.GetDirectoryEntry(); return resultDirectoryEntry.Properties["msRTCSIP-PrimaryUserAddress"

How do I validate Active Directory creds over LDAP + SSL?

纵饮孤独 提交于 2019-11-27 11:30:28
I'm trying to use the .NET 3.5 System.DirectoryServices.AccountManagement namespace to validate user credentials against our Active Directory LDAP server over an SSL encrypted LDAP connection . Here's the sample code: using (var pc = new PrincipalContext(ContextType.Domain, "sd.example.com:389", "DC=sd,DC=example,DC=com", ContextOptions.Negotiate)) { return pc.ValidateCredentials(_username, _password); } This code works fine over unsecured LDAP (port 389), however I'd rather not transmit a user/pass combination in clear text. But when I change to LDAP + SSL (port 636), I get the following

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

非 Y 不嫁゛ 提交于 2019-11-27 09:19:39
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 use the System.DirectoryServices.Protocols namespace and the LdapConnection class, whereby I can wire

System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred

允我心安 提交于 2019-11-27 07:04:32
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 the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding

ActiveDirectory error 0x8000500c when traversing properties

浪尽此生 提交于 2019-11-27 07:02:08
问题 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

Memory Leak when using DirectorySearcher.FindAll()

跟風遠走 提交于 2019-11-27 04:27:13
问题 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)"

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

元气小坏坏 提交于 2019-11-27 02:13:38
问题 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

How to programmatically change Active Directory password

岁酱吖の 提交于 2019-11-27 00:30:55
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. tvanfosson You can use the UserPrincipal class' SetPassword method, provided you have enough privileges, once you've found the correct UserPrincipal object. Use FindByIdentity to look up the principal object in question. using (var context = new PrincipalContext( ContextType.Domain )) { using (var user = UserPrincipal.FindByIdentity( context, IdentityType.SamAccountName,

System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred

有些话、适合烂在心里 提交于 2019-11-26 22:15:58
问题 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 the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred. Source Error: An