Post by rogerh on Nov 9, 2021 19:04:15 GMT
Howdy All!
We assign machines to users, which then drives OU, location, etc...
Here's my first pass/preview for the script to get the user information I need based on the username:
What I'd like to do is set the machine's OU based on the primary user's OU (not the same, but another OU on the same branch of the tree...)
We set the machine name as LEFT(LOC-DEPT-LASTNAME,15) so I'd pass the SN back as well, and have the tech validate the name.
I'd also like to try to automate some (all) of the application selections based on group membership (i.e. if member of accounting pick x, if member of sales pick y)
So my question is how do I "backfill" the UI++ variable?
In theory I'd like to something like this
Can I set variables directly that UI++ can read from an external call, or do I need to do something like write the variables out to temp text file, and then read them back?
We assign machines to users, which then drives OU, location, etc...
Here's my first pass/preview for the script to get the user information I need based on the username:
if WScript.Arguments.Count = 0 then
WScript.Echo "Missing parameters, enter the username you want info from"
end if
WScript.Echo WScript.Arguments(0)
username = WScript.Arguments(0)
Set rootDSE = GetObject("LDAP://RootDSE")
base = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">"
'filter on user objects with the given account name
fltr = "(&(objectClass=user)(objectCategory=Person)" & _
"(sAMAccountName=" & username & "))"
'add other attributes according to your requirements
attr = "distinguishedName,sn,sAMAccountName,memberof,adspath"
scope = "subtree"
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADsDSOObject"
conn.Open "Active Directory Provider"
Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandText = base & ";" & fltr & ";" & attr & ";" & scope
Set rs = cmd.Execute
Do Until rs.EOF
WScript.Echo rs.Fields("distinguishedName").Value
WScript.Echo rs.Fields("sn").Value
LDAPUPath = rs("adspath")
For Each m In rs.Fields("memberof").Value
WScript.Echo Mid(m, 4, InStr(m, ",") - 4)
Next
rs.MoveNext
Loop
rs.Close
conn.Close
What I'd like to do is set the machine's OU based on the primary user's OU (not the same, but another OU on the same branch of the tree...)
We set the machine name as LEFT(LOC-DEPT-LASTNAME,15) so I'd pass the SN back as well, and have the tech validate the name.
I'd also like to try to automate some (all) of the application selections based on group membership (i.e. if member of accounting pick x, if member of sales pick y)
So my question is how do I "backfill" the UI++ variable?
In theory I'd like to something like this
<Action Type="Input" Name="PrimaryUserInput" Title="Primary User" ShowBack="True">
<TextInput Prompt="Primary System User" Hint="Enter the name of the primary user for this system" RegEx=".*" Variable="ZZPrimaryUser" Question="Primary user for this system" ADValidate="User"/>
</Action>
<!--Set Primary User-->
<Action Type="ExternalCall" Title="External Command">'cscript.exe //NOLOGO //B QueryAD.vbs "%ZZPrimaryUser%"'</Action>
<!-- lastname, location, department get set based on this script -->
<Action Type="TSVar" Name="ZZComputerName" >"%MyLocation%-%MyDepartment%-%lastname%"</Action>
<Action Type="Input" Name="ComputerNameInput" Title="Computer Name" ShowBack="True">
<TextInput Prompt="Computer Name" Hint="Enter the name for this system" RegEx="[^\"/\\\[\]:;\|=,\+\*\?><]{3,15}" Variable="ZZComputerName" Question="Name for this system" Default="%_SMSTSMachineName%" ADValidate="ComputerWarning"/>
</Action>
Can I set variables directly that UI++ can read from an external call, or do I need to do something like write the variables out to temp text file, and then read them back?