Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » В помощь системному администратору » Как в AD создать иконки на рабочем столе?

Модерирует : lynx, Crash_Master, dg, emx, ShriEkeR

 Версия для печати • ПодписатьсяДобавить в закладки

Открыть новую тему     Написать ответ в эту тему

alyce

Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
 Добрый день.
Прошу прощение за вопрос - поиск по форуму что-то не работает.
 
Пытаюсь разобраться с Групповыми политиками в AD.  
Как Создать на рабочем столе пользователя иконки? И чтобы он не мог их менять.





Будь внимателен при написании названия темы, а то у нас и фильтр работать не будет, опечатка:
"создаnm". Исправлено.

Всего записей: 41 | Зарегистр. 26-10-2004 | Отправлено: 09:37 26-10-2004 | Исправлено: lynx, 13:01 28-10-2004
JcVai



Advanced Member
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
alyce
Для создания иконок проще пользоваться скриптами (достаточно просто кинуть shortcut-ы на рабочий стол "All users", а что касается политик, то смотри здесь

Всего записей: 661 | Зарегистр. 27-10-2002 | Отправлено: 12:45 26-10-2004
merlkerry

Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
alyce

Цитата:
Как Создать на рабочем столе пользователя иконки?

через GP можно добавить новые элементы в Active Desktop, но  правда эт не совсем то что тебя интересует - вот что буржуи пишут
 

Цитата:
Adds and deletes specified Web content items.
 
You can use the "Add" box in this policy to add particular Web-based items or shortcuts to users' desktops. Users can close or delete the items (if policies allow), but the items are added again each time the policy is refreshed.
 
You can also use this policy to delete particular Web-based items from users' desktops. Users can add the item again (if policies allow), but the item is deleted each time the policy is refreshed.
 
Note: Removing an item from the "Add" list for this policy is not the same as deleting it. Items removed from the add list are not removed from the desktop. They are just not added again.


----------
Вокруг одни враги.
Я испытываю естественный скептицизм по поводу чистоты человеческих намерений.

Всего записей: 1521 | Зарегистр. 16-09-2002 | Отправлено: 13:01 26-10-2004
alyce

Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
JcVai
 
А можно пример скрипта посмотреть?

Всего записей: 41 | Зарегистр. 26-10-2004 | Отправлено: 15:34 26-10-2004
FreemanRU



Silver Member
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
alyce
Shorcut.vbs

Код:
 
Option Explicit
 
Dim WshShell, oShellLink, Path
 
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set oShellLink = WshShell.CreateShortcut(WshShell.SpecialFolders("AllUsersDesktop")+"\Calc.lnk")
oShellLink.TargetPath = WshShell.ExpandEnvironmentStrings("%windir%\system32\calc.exe")
oShellLink.IconLocation = WshShell.ExpandEnvironmentStrings("%windir%\system32\calc.exe") & ", 0"
oShellLink.Save
 
Set oShellLink = Nothing
 

 
Добавлено
У меня стоит как стар-ап скрипт для компа. Тока надо учесть, что в этом случае он выполняется от имени SYSTEM и соотвественно у неё должен быть доступ на редактирование папки, в которой создается ярлык и чтение той папки, где находиться TargetPath и IconLocation

Всего записей: 3796 | Зарегистр. 16-07-2004 | Отправлено: 00:51 28-10-2004
Lodo



Newbie
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
Кстати в продолжение темы.  
У меня к активэ подключена смешанная группа пользователей, 2000, ХР, 98 - вопрос как при помощи скрипта сделать у нового пользователя прошедшего авторизацию через сервак с 2000, на рабочем столе появилась иконка, без возможности изменить, данную. То есть стоит вопрос как забить в профиль пользователю иконку на его рабочий стол. Если 98 понятно, то как быть с  ХР и 2000.

Всего записей: 10 | Зарегистр. 01-06-2002 | Отправлено: 12:11 18-04-2006
Gremlin19



Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Тема как я понимаю старая, но всё-таки...  
имею вот такой скрипт 100% рабочий
раздает ярлычки, цепляет принтеры и мапит диски согласно группам в АД:

Код:
'***********************************************************************************************************'
' File:     RU-ALL-CONNECT-PRN.VBS
' Script connects network printers if user is a member of specific group
' Also creates shortcut on user's desktop
' Code written : Nikolay Ermakov'
' Date : 06 May 2005'
' Release : 2'
'***********************************************************************************************************'  
' Initialize vars
' ********* Change this for testing ****************
Const strDomain = "YOURDOMAIN.RU" 'Domain of the user
Const UseNTServer = 0   'Sets whether this script runs when logging on locally
                        'to Windows Servers.
                        'Values are: 1 (Yes) OR 0 (No)
 
Dim strPrnFilename : strPrnFilename = "Printerlist.csv"    'Printer cfg file name
Dim strLnkFilename : strLnkFilename = "Linklist.csv"    'Shortcuts cfg file name
Dim strDrvFilename : strDrvFilename = "Drivelist.csv"    'Drives cfg file name
Dim objWshNetwork : Set objWshNetwork = CreateObject("Wscript.Network")
Dim strLogonPath        'Path to location from where the script is running
Dim strOSProdType       'OS Product type (WinNT, LanmanNT, ServerNT)
Dim strWorkstation      'Local Computer Name
Dim objWshShell
Dim strUserID  
Dim GroupList
Dim objIntExplorer
Dim freeletter
'Dim strTarget, strArguments , strDesktop
' ************************************************************************************************************'
 
On Error Resume Next
 
Set fso = CreateObject("Scripting.FileSystemObject")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set objWshShell = CreateObject( "WScript.Shell" )
 
strUserID = objWshNetwork.UserName
strCompID = objWshNetwork.ComputerName & "$"
 
'Gather some basic system info
Call GetSystemInfo
 
If IsTerminalServerSession = True Then ' Exit if the script is running in a terminal server sessionend if
    'Wscript.Echo "Terminal session"
    'Call CleanUp  
End if
 
'Exit if we are logging on locally to a server and the script is set to NOT run on servers
If UseNTServer = 0 AND (strOSProdType = "LanmanNT" OR strOSProdType = "ServerNT") AND Not (IsTerminalServerSession) Then  
    Call CleanUp
End If  
 
 
'Setup IE for use as a status message window
'Call SetupIE
'Display welcome message
'Call UserPrompt ("Welcome " & strUserID)
'Add horizontal line as a 'break'
'objIntExplorer.Document.WriteLn("<hr style=""width:100%""></hr>")
 
strPrnFilename = strLogonPath & "\" & strPrnFilename
strLnkFilename = strLogonPath & "\" & strLnkFilename
strDrvFilename = strLogonPath & "\" & strDrvFilename
 
'Check for error getting username
If strUserID = "" Then
  objWshShell.Popup "Logon script failed - Contact the Helpdesk @ x 1234", ,"Logon script", 48
  End If
 
If fso.FileExists(strDrvFilename) Then            'If DriveMapping cfg file exists
    Set drvlist = Fso.OpenTextFile(strDrvFilename)
    ' make File into an Array
    aGroup = Split(drvlist.Readall,vbcrlf)
    For x = 1 to UBound(aGroup) ' Read the entire CSV from the second line
        driveline = aGroup(x)
        Group = Left(driveline,InStr(driveline,",")-1) 'Extract group list
        if ADSI_IsMemberOfGroup(strDomain, strUserID, Group) Then ' If you're in the group
'            MsgBox "Member of the group " & Group
            ' It is a member - Connect drive
            driveline = Mid(driveline,InStr(driveline,",")+1) ' Remove the GroupName from the line
            Drive = Left(driveline,InStr(driveline,",")-1) ' Extract Drive Letter
            Path = Mid(driveline,InStr(driveline,",")+1) ' Extract the path
            'Wscript.Echo "GroupName: " & vbTab & Group & vbCr _
            '& "----------------------------------" & vbCr _
            '& "Drive Letter: " & vbTab & Drive & vbCr _
            '& "Drive Path: " & vbTab & Path & vbCr _
            '& ""  
            on Error Resume Next
            If drive = "*" then    'Connect to any free drive letter if drive letter configured as "*"
                For freeletter = Asc("K") to Asc("Z")  
                    If Not fso.driveExists (chr(freeletter)) Then
                        drive = (Chr(freeletter)) & ":"    
                        Exit For  
                    End If  
                Next  
            end if
            If (fso.DriveExists(drive) <> True) and (Drive<>"!!") Then ' If The Drive is not already mapped
                objWshNetwork.MapNetworkDrive drive,path ' Map The Drive
                wscript.sleep 300
            End If  
        End If
    Next
End If
 
If fso.FileExists(strPrnFilename) Then            'If Printer cfg file exists
    Set prnlist = Fso.OpenTextFile(strPrnFilename)
    ' make File into an Array
    aGroup = Split(prnlist.Readall,vbcrlf)
    For x = 1 to UBound(aGroup) ' Read the entire CSV from the second line
        printerline = aGroup(x)
        Group = Left(printerline,InStr(printerline,",")-1) 'Extract group list
        if ADSI_IsMemberOfGroup(strDomain, strUserID, Group) Then ' If you're in the group
'            MsgBox "Member of the group " & Group
            ' It is a member - Connect printer
            Path = Mid(printerline,InStr(printerline,",")+1) ' Extract the path
            on Error Resume Next
            'Call UserPrompt ("Successfully added printer connection to: " & Path)
            objWshNetwork.AddWindowsPrinterConnection Path
            wscript.sleep 300
        End If
    Next
End If
 
If fso.FileExists(strLnkFilename) Then            'If Shortcut cfg file exists
    Set lnklist = Fso.OpenTextFile(strLnkFilename)
    ' make File into an Array
    aGroup = Split(lnklist.Readall,vbcrlf)
    strDesktop = objWshShell.SpecialFolders("Desktop")
    
    For x = 1 to UBound(aGroup) ' Read the entire CSV from the second line
        linkline = aGroup(x)
        Group = Left(linkline,InStr(linkline,",")-1) 'Extract group list
'        if ADSI_IsMemberOfGroup(strDomain, strUserID, Group) then MsgBox "User is Member of the group " & Group end if
'        if ADSI_CompIsMemberOfGroup (strDomain, strCompID, Group) Then MsgBox "Comp is Member of the group " & Group end if
        if ADSI_IsMemberOfGroup(strDomain, strUserID, Group) or ADSI_CompIsMemberOfGroup (strDomain, strCompID, Group) Then
        ' If you're in the group
        ' It is a member - Create shortcut
            linkline = Mid(linkline,InStr(linkline,",")+1) ' Remove the GroupName from the line
            LinkName = Left(linkline,InStr(linkline,",")-1) 'Extract shortcut name
            linkline = Mid(linkline,InStr(linkline,",")+1) ' Remove the LinkName from the line
            strTarget = Left(linkline,InStr(linkline,",")-1) 'Extract shortcut target (path to program)
            linkline = Mid(linkline,InStr(linkline,",")+1) ' Remove the Target from the line
            strArguments = Left(linkline,InStr(linkline,",")-1) 'Extract arguments
            linkline = Mid(linkline,InStr(linkline,",")+1) ' Remove the arguments from the line
            strWDir = Left(linkline,InStr(linkline,",")-1) ' Extract Working dir
            linkline = Mid(linkline,InStr(linkline,",")+1) ' Remove Working dir from the line
            strIconLoc = linkline ' Extract the Icon Location
            on Error Resume Next
            set oSLink = objWshShell.CreateShortcut(strDesktop & "\" & LinkName)
            oSLink.TargetPath = strTarget     ' you can use UNC instead of driveletter as well
            oSLink.Arguments = strArguments
            oSLink.IconLocation = strIconLoc
            oSLink.WorkingDirectory = strWDir
            oSLink.Save                 ' create the shortcut
        End If
    Next
End If
 
 
'Inform user that logon process is done
'Add horizontal line as a 'break'
'objIntExplorer.Document.WriteLn("<hr style=""width:100%""></hr>")
'Call UserPrompt ("Finished network logon processes")
'Wait 10 seconds
'Wscript.Sleep (10000)
'Close Internet Explorer
'objIntExplorer.Quit( )
Call CleanUp 'This is end of running script
 
 
'ADSI_IsMemberOfGroup.asp -- last revision 2003-11-12 TGH
'-------------------------------------------------------------------------------
'Copyright (c) 2003, Thomas G. Harold and Beta Research Corp, All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification,  
'are permitted provided that the following conditions are met:
'
' * Redistributions of source code must retain the above copyright notice, this  
'   list of conditions and the following disclaimer.
' * Redistributions in binary form must reproduce the above copyright notice, this  
'   list of conditions and the following disclaimer in the documentation and/or other  
'   materials provided with the distribution.
' * Neither the name of Beta Research Corp nor the names of its contributors may be used  
'   to endorse or promote products derived from this software without specific prior  
'   written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY  
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES  
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT  
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  
'PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  
'INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT  
'LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  
'OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'-------------------------------------------------------------------------------
 
'ADSI_IsMemberOfGroup(sDomain,sUserName,sGroup)
'
'Returns TRUE if the user is a member of group X, also searches through nested groups
'Failure mode results in FALSE being returned.
'Assumption is that both the USERNAME and the GROUPNAME are in the same DOMAIN
'Another assumption is that the domain that is passed in is also that of the current
'Active Directory tree.  (Bad assumption, but I can't find code to map a NT style
'domain name to the active directory equivalent.)
'
'sDomainName = "DOMAIN" (left side of the Request.ServerVariables("AUTH_USER") variable)
'sUserName = "USERNAME" (right side of the Request.ServerVariables("AUTH_USER") variable)
'sGroup = "GROUPNAME" name of the ADSI group that the user has to be a member of
'
'Example: If ADSI_IsMemberOfGroup("DOMAIN1", "Scott", "Domain Administrators") Then
 
Private Function ADSI_IsMemberOfGroupRecurse( sRootDomain,  sParentDN, sUsername)
    'Response.Write "ADSI_IsMemberOfGroupRecurse([" & sRootDomain & "], [" & sParentDN & "], [" & sUsername & "])<br>" & vbCrLf
 
    Dim oConn, oCommand, bFound
    bFound = False
    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")    
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn
     
    'Check for direct membership    
    oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
        "FROM 'LDAP://" & sRootDomain & "' " & _
        "WHERE memberOf='" & sParentDN & "' " & _
        "AND SAMAccountName='" & sUserName & "' " & _
        "AND objectClass='user' ORDER BY NAME"
    Set rsLDAP = oCommand.Execute
    If Not rsLDAP.EOF Then
        'Response.Write "DIRECT MEMBER! Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
        '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
        '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
        '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf
        bFound = True
    End If
     
    If Not bFound Then
        'Otherwise get the list of groups within the current group and recurse into them
        oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
            "FROM 'LDAP://" & sRootDomain & "' " & _
            "WHERE memberOf='" & sParentDN & "' AND objectClass='group' ORDER BY NAME"
        Set rsLDAP = oCommand.Execute
        While (Not rsLDAP.EOF) And (Not bFound)
            'Response.Write "SUB-GROUP: Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
            '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
            '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
            '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf      
            bFound = ADSI_IsMemberOfGroupRecurse(sRootDomain, rsLDAP.Fields("DistinguishedName"), sUserName)            
            rsLDAP.MoveNext
        Wend
    End If
 
    Set oCommand = Nothing
    Set oConn = Nothing
    ADSI_IsMemberOfGroupRecurse = bFound
End Function
 
Public Function ADSI_IsMemberOfGroup( sDomain, sUserName, sGroup )
    ADSI_IsMemberOfGroup = False    
    'Response.Write "ADSI_IsMemberOfGroup([" & sDomain & "], [" & sUserName & "], [" & sGroup & "])<br>" & vbCrLf
 
    'NOTE: We're making the assumption that there is only ONE domain, and that it's
    'the proper domain that happens to match the sDomain parameter.
    Set oRoot = GetObject("LDAP://RootDSE")
    sRootDomain = oRoot.Get("DefaultNamingContext")
    'Response.Write "sRootDomain=[" & sRootDomain & "]<br>" & vbCrLf
     
    Dim oConn, oCommand, oRoot, sRootDomain
    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")    
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn
         
    'Get the group's distinguished name information
    Dim GroupDistinguishedName
    oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
        "FROM 'LDAP://" & sRootDomain & "' " & _
        "WHERE SAMAccountName='" & sGroup & "' ORDER BY NAME"
    Set rsLDAP = oCommand.Execute
    If Not rsLDAP.EOF Then
        'Response.Write "GROUP DISTINGUISHED NAME: Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
        '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
        '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
        '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf
        GroupDistinguishedName = rsLDAP.Fields("DistinguishedName")
    End If
 
    ADSI_IsMemberOfGroup = ADSI_IsMemberOfGroupRecurse( sRootDomain, GroupDistinguishedName, sUsername)
     
    Set oCommand = Nothing
    Set oConn = Nothing
    Set oRoot = Nothing
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Sub:      SetupIE
'
' Purpose:  Set up Internet Explorer for use as a status message window
'
' Input:
'
' Output:
'
' Usage:    Call SetupIE
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Private Sub SetupIE
  On Error Resume Next
  Dim strTitle    'Title of IE window
  Dim intCount    'Counter used during AppActivate
  strTitle = "Logon script status"
  'Create reference to objIntExplorer
  'This will be used for the user messages. Also set IE display attributes
  Set objIntExplorer = Wscript.CreateObject("InternetExplorer.Application")
  With objIntExplorer
    .Navigate "about:blank"
    .ToolBar   = 0
    .Menubar   = 0
    .StatusBar = 0
    .Width     = 600
    .Height    = 350
    .Left      = 100
    .Top       = 100
  End With
 
  'Set some formating
 
  With objIntExplorer.Document
    .WriteLn ("<!doctype html public>")
    .WriteLn   ("<head>")
    .WriteLn    ("<title>" & strTitle & "</title>")
    .WriteLn     ("<style type=""text/css"">")
    .WriteLn      ("body {text-align: left; font-family: Courier New; font-size: 8pt}")
    .WriteLn     ("</style>")
    .WriteLn   ("</head>")
  End With
  'Wait for IE to finish
  Do While (objIntExplorer.Busy)
    Wscript.Sleep 200
  Loop
  'Show IE
  objIntExplorer.Visible = 1
  'Make IE the active window
  For intCount = 1 To 100
    If objWshShell.AppActivate(strTitle) Then Exit For
    WScript.Sleep 50
  Next
 
End Sub
 
 
' Sub:      UserPrompt
'
' Purpose:  Use Internet Explorer as a status message window
'
' Input:    strPrompt
'
' Output:   Output is sent to the open Internet Explorer window
'
' Usage:
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Private Sub UserPrompt( strPrompt )
  On Error Resume Next
  objIntExplorer.Document.WriteLn (strPrompt & "<br />")
End Sub
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Sub:      Cleanup
' Purpose:  Release common objects and exit script
' Input:
' Output:
' Usage:    Call Cleanup
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Cleanup
  On Error Resume Next
  Set objFileSys     = Nothing
  Set objWshNetwork  = Nothing
  Set objWshShell    = Nothing
  Set objIntExplorer = Nothing
  ' Exit script
  WScript.Quit( )
End Sub
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      GetSystemInfo
' Purpose:  Gather basic information about the local system
' Input:
' Output:   strDomain, strOSProdType, strWorkstation, strLogonPath
' Usage:    Call GetSystemInfo
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub GetSystemInfo
  On Error Resume Next
  'Get domain name
  If objWshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then
    strDomain = objWshNetwork.UserDomain
  Else
    strDomain = objWshShell.RegRead( "HKLM\System\CurrentControlSet\" & _
                "Services\MSNP32\NetWorkProvider\AuthenticatingAgent" )
  End If
  'Get Product Type from Registry (WinNT, LanmanNT, ServerNT)
  strOSProdType = objWshShell.RegRead( _
    "HKLM\System\CurrentControlSet\Control\ProductOptions\ProductType")
  'Get computer name
  If IsTerminalServerSession = True Then
    'Set strWorkstation to the real name and not the name of the server
    strWorkstation = objWshShell.ExpandEnvironmentStrings( "%CLIENTNAME%" )
  Else
    strWorkstation = objWshNetwork.ComputerName
  End If
  'Get the path to the location from where the script is running
  strLogonPath = Left( Wscript.ScriptFullName, _
    ( InstrRev( Wscript.ScriptFullName, "\") -1))
End Sub
 
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: IsTerminalServer
' Purpose:  Determine if the script is running in a terminal server session
' Input:
' Output:
'           True if running in a terminal server session
'           False if not running in a terminal server session
' Usage:
'           If IsTerminalServerSession = True Then <Do Something>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IsTerminalServerSession
  On Error Resume Next
  Dim strName
  'Detect if this is a terminal server session
  'If it is, set some names to the terminal server client name
  strName = objWshShell.ExpandEnvironmentStrings( "%CLIENTNAME%" )
  If strName <> "%CLIENTNAME%" AND strName <> "" Then  
    IsTerminalServerSession = True
  Else
    IsTerminalServerSession = False
  End if
End Function
 
Private Function ADSI_CompIsMemberOfGroupRecurse( sRootDomain,  sParentDN, sCompName)
    'Response.Write "ADSI_IsMemberOfGroupRecurse([" & sRootDomain & "], [" & sParentDN & "], [" & sUsername & "])<br>" & vbCrLf
 
    Dim oConn, oCommand, bFound
    bFound = False
    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")    
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn
     
    'Check for direct membership    
    oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
        "FROM 'LDAP://" & sRootDomain & "' " & _
        "WHERE memberOf='" & sParentDN & "' " & _
        "AND SAMAccountName='" & sCompName & "' " & _
        "AND objectClass='computer' ORDER BY NAME"
    Set rsLDAP = oCommand.Execute
    If Not rsLDAP.EOF Then
        'Response.Write "DIRECT MEMBER! Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
        '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
        '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
        '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf
        bFound = True
    End If
     
    If Not bFound Then
        'Otherwise get the list of groups within the current group and recurse into them
        oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
            "FROM 'LDAP://" & sRootDomain & "' " & _
            "WHERE memberOf='" & sParentDN & "' AND objectClass='group' ORDER BY NAME"
        Set rsLDAP = oCommand.Execute
        While (Not rsLDAP.EOF) And (Not bFound)
            'Response.Write "SUB-GROUP: Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
            '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
            '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
            '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf      
            bFound = ADSI_CompIsMemberOfGroupRecurse(sRootDomain, rsLDAP.Fields("DistinguishedName"), sCompName)            
            rsLDAP.MoveNext
        Wend
    End If
 
    Set oCommand = Nothing
    Set oConn = Nothing
    ADSI_CompIsMemberOfGroupRecurse = bFound
End Function
 
Public Function ADSI_CompIsMemberOfGroup( sDomain, sCompName, sGroup )
    ADSI_CompIsMemberOfGroup = False    
    'Response.Write "ADSI_IsMemberOfGroup([" & sDomain & "], [" & sUserName & "], [" & sGroup & "])<br>" & vbCrLf
 
    'NOTE: We're making the assumption that there is only ONE domain, and that it's
    'the proper domain that happens to match the sDomain parameter.
    Set oRoot = GetObject("LDAP://RootDSE")
    sRootDomain = oRoot.Get("DefaultNamingContext")
    'Response.Write "sRootDomain=[" & sRootDomain & "]<br>" & vbCrLf
     
    Dim oConn, oCommand, oRoot, sRootDomain
    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")    
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn
         
    'Get the group's distinguished name information
    Dim GroupDistinguishedName
    oCommand.CommandText = "SELECT SAMAccountName, Name, DistinguishedName, ADSPath " & _
        "FROM 'LDAP://" & sRootDomain & "' " & _
        "WHERE SAMAccountName='" & sGroup & "' ORDER BY NAME"
    Set rsLDAP = oCommand.Execute
    If Not rsLDAP.EOF Then
        'Response.Write "GROUP DISTINGUISHED NAME: Name=[<b>" & rsLDAP.Fields("Name") & "</b>] SAMAccountName=[<b>" & _
        '   rsLDAP.Fields("SAMAccountName") & "</b>] DistinguishedName=[<b>" & _
        '   rsLDAP.Fields("DistinguishedName") & "</b>] ADsPath=[" & _
        '   rsLDap.Fields("ADsPath") & "]<br>" & vbCrLf
        GroupDistinguishedName = rsLDAP.Fields("DistinguishedName")
    End If
 
    ADSI_CompIsMemberOfGroup = ADSI_CompIsMemberOfGroupRecurse( sRootDomain, GroupDistinguishedName, sCompName)
     
    Set oCommand = Nothing
    Set oConn = Nothing
    Set oRoot = Nothing
End Function
 
 

 
в скрипте используются три файла с описанием
linklist.csv

Код:
Group name,        Shortcut name,        Target,        Arguments,        WorkingDir,        IconLocation
LNK-ATS,АТС.lnk,\\servername\sharename\АТС.xls,,\\servername\sharename\,\\servername\sharename\АТС.xls,0
 

printerlist.csv

Код:
 
GroupName, PrinterPath
Account,\\ones\Account-Xerox-3300MFP
credit,\\credit2\hplj1320

 ну и drivelist.csv

Код:
GroupName, DriveLetter, DrivePath
 
drive_N group,N:,\\srv01\Share
drive_X group,X:,\\srv02.youtrusteddomain.ru\Share_Vidnoe

 
ярлычки создаются, принтеры цепляются, и диски мапятся.  
Но есть один вопрос, как можно удалить созданные таким методом ярлычки?

Всего записей: 125 | Зарегистр. 06-03-2006 | Отправлено: 09:00 11-03-2011
Gremlin19



Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
как можно удалить созданные таким методом ярлычки/принтеры?
диски при логофф-е не сохраняются и мапяться при каждом выполнении скрипта

Всего записей: 125 | Зарегистр. 06-03-2006 | Отправлено: 12:37 06-04-2011
bpost



Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
https://accessbaseddesktop.codeplex.com/

Всего записей: 62 | Зарегистр. 14-06-2006 | Отправлено: 22:43 21-10-2014
Открыть новую тему     Написать ответ в эту тему

Компьютерный форум Ru.Board » Компьютеры » В помощь системному администратору » Как в AD создать иконки на рабочем столе?


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru