ささいなこと5、または「グループの喜び」を経験しました。

画像 「実験的なささいなこと」の継続。 前のパーツ: onetwothreefour



この投稿では、Active Directoryのグループについて説明します。 私は理論に深く入り込むことはせず、普遍的でグローバルなローカルグループについては語りません。多くの詳細があるので、文書のすべての詳細を見つけることができます。 グループが一般的に必要とされる理由と、彼らの助けを借りてどのような「グッズ」が得られるかについて話しましょう。







例として、この原則に基づいて動作するスクリプトを示します。ユーザーがどのグループに属しているかを判別し、 RDP_プレフィックスが含まれるグループを見つけ、次のパラメーターを使用してデスクトップにユーザーのRDPショートカットを作成します。

その結果、誰かを1Cサーバーに入れるには、グループに追加して、システムに再入室するように頼むだけです。 さらに、リモート管理者とRDP_GroupNameグループのメンバーは、アカウンティングターミナルサーバーへのリモートアクセスが許可されます。



' RDP- , .

' - RDP_ Description , RDP-

' AD- RDP_1C- Server1.domain.local Desription

' - , .

' RDP- .

On Error Resume Next

Set wshShell = WScript.CreateObject("WScript.Shell")

Set m_FSO = CreateObject("Scripting.FileSystemObject")



' AD

Set objSysInfo = CreateObject("ADSystemInfo")

ADSPath = "LDAP://" & objSysInfo.UserName

Set objUser = GetObject(ADSPath)

ShortUserName = objUser.SamAccountName

DomainName = objSysInfo.DomainShortName



'

DesktopPath = wshShell.SpecialFolders("Desktop")

LevelCount = 0

MaxLevelCount = 4

Status = CheckGroups(ADSPath)



'

'============ Function GetPrefixNameGroup ============

Function GetPrefixNameGroup(sString)

' Trim prefix of name group

Dim TempString

TempString = Left(sString, InStr(sString, "_"))

GetPrefixNameGroup = TempString

End Function

'=====================================================

'============ Function GetLinkNameGroup ============

Function GetLinkNameGroup(sString)

' Trim LinkName of name group

Dim TempString

TempString = Mid(sString, InStrRev(sString, "_")+1)

GetLinkNameGroup = TempString

End Function

'=====================================================

'============ Function Create RdpFile ============

Function CreateRDPFile(sString, sName)

spath = DesktopPath & "\" & sString & ".rdp"

' - - '

If m_FSO.FileExists(sPath) or m_FSO.FolderExists(sPath) Then

m_FSO.DeleteFile (sPath),1

End If

Set RDPFile = m_FSO.CreateTextFile (spath, True)

RDPFile.writeline ("screen mode id:i:2")

RDPFile.writeline ("use multimon:i:0")

RDPFile.writeline ("desktopwidth:i:1280")

RDPFile.writeline ("desktopheight:i:1024")

RDPFile.writeline ("session bpp:i:16")

RDPFile.writeline ("winposstr:s:0,1,0,0,800,600")

RDPFile.writeline ("compression:i:1")

RDPFile.writeline ("keyboardhook:i:2")

RDPFile.writeline ("audiocapturemode:i:0")

RDPFile.writeline ("videoplaybackmode:i:1")

RDPFile.writeline ("connection type:i:2")

RDPFile.writeline ("displayconnectionbar:i:1")

RDPFile.writeline ("disable wallpaper:i:1")

RDPFile.writeline ("disable full window drag:i:1")

RDPFile.writeline ("allow desktop composition:i:0")

RDPFile.writeline ("allow font smoothing:i:0")

RDPFile.writeline ("disable menu anims:i:1")

RDPFile.writeline ("disable themes:i:1")

RDPFile.writeline ("disable cursor setting:i:0")

RDPFile.writeline ("bitmapcachepersistenable:i:1")

' '

RDPFile.writeline ("full address:s:" & sName)

RDPFile.writeline ("audiomode:i:2")

RDPFile.writeline ("redirectprinters:i:0")

RDPFile.writeline ("redirectcomports:i:0")

RDPFile.writeline ("redirectsmartcards:i:0")

RDPFile.writeline ("redirectclipboard:i:1")

RDPFile.writeline ("redirectposdevices:i:0")

RDPFile.writeline ("redirectdirectx:i:1")

RDPFile.writeline ("autoreconnection enabled:i:1")

RDPFile.writeline ("authentication level:i:0")

RDPFile.writeline ("prompt for credentials:i:0")

RDPFile.writeline ("negotiate security layer:i:1")

RDPFile.writeline ("remoteapplicationmode:i:0")

RDPFile.writeline ("alternate shell:s:")

RDPFile.writeline ("shell working directory:s:")

RDPFile.writeline ("gatewayhostname:s:")

RDPFile.writeline ("gatewayusagemethod:i:4")

RDPFile.writeline ("gatewaycredentialssource:i:4")

RDPFile.writeline ("gatewayprofileusagemethod:i:0")

RDPFile.writeline ("promptcredentialonce:i:1")

' Domain\Username'

RDPFile.writeline ("username:s:" & DomainName& "\"& ShortUserName)

RDPFile.writeline ("drivestoredirect:s:")

RDPFile.close

End Function

'=====================================================

'============ Function CheckGroups ===================

Function CheckGroups(ADSPath)

Dim objUser, arrMemberOf

Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D

LevelCount = LevelCount + 1

if ( LevelCount >= MaxLevelCount) then

LevelCount = LevelCount - 1

return LevelCount

end If

Set objUser = GetObject (ADSPath)

On Error Resume Next

arrMemberOf = objUser.GetEx("memberOf")

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then

LevelCount = LevelCount - 1

return LevelCount

Else

For Each Group in arrMemberOf

ADSGroup = "LDAP://" & Group

CheckGroups(ADSGroup)

WScript.Echo "Extra=" & LevelCount

Set objGroup = GetObject ( ADSGroup )

If(GetPrefixNameGroup(objGroup.CN) = "RDP_") Then

Set objGroup = GetObject ( "LDAP://" & Group)

LinkName = GetLinkNameGroup(objGroup.CN)

LinkServer = objGroup.description

LinkResult = CreateRDPFile (LinkName, LinkServer)

end If

Next

End If

LevelCount = LevelCount - 1

End Function

'=====================================================






そして、スクリプトのシートで繰り返されないために、そして「システム管理者の正当な好奇心」を扇動することに加えて、例2はADからのスクリーンショットになります。

画像

ここでは、同様のスクリプトを使用して、1Cデータベースをユーザーに追加します。 さらに、ご想像のとおり、ユーザーはターミナルのデータベースの一部(2つの異なるデータベース)で作業し、パスを追加するスクリプトはターミナル自体で実行されるため、パスはローカルになります。 拠点の他の部分(給与)では、ネットワーク経由で、スクリプトはワークステーションで実行されますが、これは一般に重要ではありませんが、ユーザーに追加する方法は関係ありません。 自分でこれを行う場合-1C7.7と1C8.Xでは、それぞれデータベースにパスを追加するための異なる原則があり、スクリプト本体に異なるスクリプトまたは2つの異なる関数が必要であることを忘れないでください。

さらに良いことに、最初に必要なものをすべて書き込んでからプログラムを起動するスクリプトを使用して、1C自体を直接起動します。



続く



PS教えてください。 Habréの場合と同様に、スクリプトと一般的なコードをレイアウトする方が適切です。



All Articles