Showing posts with label adsi. Show all posts
Showing posts with label adsi. Show all posts

Saturday, 29 June 2024

Управление группами безопасности в AD.


Всем привет.

Рассмотрим управление группами безопасности в каталоге Active Directory с помощью ADSI. Рассмотрим как простые операции с группами: создание, поиск групп, чтение свойств, так и сложные - копирование списков безопасности.

Создание группы безопасности.

# Название создаваемой группы

$GroupName="..."

# Путь к контейнеру, в котором будет создана группа

$objOU=[ADSI]"LDAP://OU=...,DC=test,DC=domain,DC=com"

$objGroup = $objOU.Create("group", "CN=" + $GroupName)

$objGroup.Put("sAMAccountName", $GroupName)

$objGroup.SetInfo()

Для создания группы безопасности в каталоге Active Directory необходимо знать путь к контейнеру, в котором будет создана группа и название самой группы. По умолчанию создается Global Security группа (groupType=-2147483646).

Wednesday, 26 June 2024

Query by ADSI and ADSISearcher.

Hi all.

This post will examine the difference between PowerShell ADSI and ADSISearcher when using PowerShell to query Active Directory. ADSI and ADSISearcher are used to query Active Directory (AD) using Lightweight Directory Access Protocol (LDAP).


WHAT IS LDAP?

LDAP, as the name suggests, is a protocol that provides an interface to query AD directory services.  When we are querying AD we are returning one or more objects with unique identifiers (a Distinguished Name).  And we can do this using two type accelerators called ADSI and ADSISearcher.


WHAT IS A TYPE ACCELERATOR?

A type accelerator is a simple alias to represent a .Net class.  We can return a list of type accelerators like so:

[System.Management.Automation.PSObject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::Get

You’ll notice that one of the type accelerators is psobject which references the class System.Management.Automation.PSObject. This means we could simplify our command above by using a type accelerator to get a list of all the type accelerators like so!

[psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::Get

Версия на печать

Популярное