我有一個 Powershell 命令
New-ADGroup -Name "Group_Name" -SamAccountName Group_Name -GroupCategory Security -GroupScope Global -DisplayName "Group_Name" -Path "CN=Users,DC=domain,DC=local"
我正在嘗試將其轉換為這個 python 代碼(使用 ldap)
...
attrs = dict(sAMAccountName=group_name)
attrs.update(GroupCategory=1)
attrs.update(GroupScope='Global')
attrs.update(DisplayName=group_name)
attrs.update(Path='CN=Users,DC=devfactory,DC=local')
connection = self.create_ad_connection(ad_server)
entry = connection.add(distinguished_name, object_class='group', attributes=attrs)
...
我收到此錯誤:
Exception has occurred: LDAPAttributeError
invalid attribute type GroupCategory
如何在 python 上設定GroupCategory 和其他屬性?任何幫助表示贊賞。
uj5u.com熱心網友回復:
GroupCategory
(也稱為“組型別”)和都GroupScope
在屬性中設定groupType
,這是一個位掩碼(或位標志):一個二進制值,其中每個位都是具有不同含義的開/關標志。檔案的備注部分告訴groupType
我們,第 2位使其成為全域組,第 32位(十進制值為2,147,483,648)使其成為安全組。
如果要將其設定為全域安全組,可以將groupType
屬性設定為兩個十進制值之和:2 2147483648 = 2147483650
attrs.update(groupType=2147483650)
二進制值如下所示:
10000000000000000000000000000010
兩個 1 是使其成為全球安全組的原因。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/474167.html
標籤:python-3.x 电源外壳 活动目录