Adding and removing users from Active Directory groups in .NET

Ugh. LDAP. If you’re using the .Net Framework 3.5 or above, I highly recommend using the System.DirectoryServices.AccountManagement namespace. That makes things so much easier. public void AddUserToGroup(string userId, string groupName) { try { using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, “COMPANY”)) { GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, groupName); group.Members.Add(pc, IdentityType.UserPrincipalName, userId); group.Save(); } } catch (System.DirectoryServices.DirectoryServicesCOMException E) … Read more

ASP.NET Core 2.0 LDAP Active Directory Authentication

Thanks to Win’s Answer for pointing out that I needed to use Windows Compatibility Pack, I was able to figure this out. The first thing I had to do was install the Nuget package Install-Package Microsoft.Windows.Compatibility At the time, I needed a preview version, so I appended -Version 2.0.0-preview1-26216-02 on the end of this command … Read more

Querying Windows Active Directory server using ldapsearch from command line

The short answer is “yes”. A sample ldapsearch command to query an Active Directory server is: ldapsearch \ -x -h ldapserver.mydomain.example \ -D “mywindowsuser@mydomain.example” \ -W \ -b “cn=users,dc=mydomain,dc=com” \ -s sub “(cn=*)” cn mail sn This would connect to an AD server at hostname ldapserver.mydomain.example as user mywindowsuser@domain.example, prompt for the password on the … Read more

Is there any free ldap server with data? [closed]

Here you go: Online LDAP Test Server It’s free, contains data, browsable. Make sure you use LDAP v3 when trying to bind. Example of using from command line: ldapsearch -W -h ldap.forumsys.com -D “uid=tesla,dc=example,dc=com” -b “dc=example,dc=com” Password: password Returns: # extended LDIF # # LDAPv3 # base <dc=example,dc=com> with scope subtree # filter: (objectclass=*) # … Read more

What does LDAP solve?

What is LDAP? What are the scenarios where LDAP is the right choice? At its core, LDAP is a protocol for accessing objects that are suitable for storage in a directory. Whether something is “suitable” is an entirely subjective determination that’s left up to implementers, but typically this means collections of many objects that each … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)