% LaTeX document produced by pod2latex from "lanman.pm.pod". % The followings need be defined in the preamble of this document: %\def\C++{{\rm C\kern-.05em\raise.3ex\hbox{\footnotesize ++}}} %\def\underscore{\leavevmode\kern.04em\vbox{\hrule width 0.4em height 0.3pt}} %\setlength{\parindent}{0pt} \section{LANMAN.PM}% \index{LANMAN.PM} \subsection*{NAME Win32::Lanman --- implements MS Lanmanager functions =head1 SYNOPSIS use Win32::Lanman; =head1 DESCRIPTION This module implements the MS Lanmanager functions =head1 CONSTANTS Documentation for use and meaning of the Constants can be found at the section on {\em http://search.microsoft.com/us/dev/default.asp\/} SERVICE\underscore{}CONTROL\underscore{}DESCRIPTIONS SERVICE\underscore{}STATE\underscore{}DESCRIPTIONS SERVICE\underscore{}CONTROLS SERVICE\underscore{}START\underscore{}TYPES SERVICE\underscore{}ERROR\underscore{}TYPES SERVICE\underscore{}ACCEPTED\underscore{}CONTROLS SERVICE\underscore{}ADAPTER SERVICE\underscore{}RECOGNIZER\underscore{}DRIVER SERVICE\underscore{}TYPE\underscore{}ALL SERVICE\underscore{}STATES SERVICE\underscore{}TYPES AF\underscore{}OP\underscore{}ACCOUNTS AF\underscore{}OP\underscore{}COMM AF\underscore{}OP\underscore{}PRINT AF\underscore{}OP\underscore{}SERVER ALLOCATE\underscore{}RESPONSE AuditCategoryAccountLogon AuditCategoryAccountManagement AuditCategoryDetailedTracking AuditCategoryDirectoryServiceAccess AuditCategoryLogon AuditCategoryObjectAccess AuditCategoryPolicyChange AuditCategoryPrivilegeUse AuditCategorySystem AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}ENC\underscore{}TKT\underscore{}IN\underscore{}SKEY AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}FORWARDABLE AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}NOADDRESS AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}POSTDATE AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}PROXIABLE AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}RENEWABLE AUTH\underscore{}REQ\underscore{}ALLOW\underscore{}VALIDATE AUTH\underscore{}REQ\underscore{}OK\underscore{}AS\underscore{}DELEGATE AUTH\underscore{}REQ\underscore{}PREAUTH\underscore{}REQUIRED AUTH\underscore{}REQ\underscore{}VALIDATE\underscore{}CLIENT Batch CONNECT\underscore{}CURRENT\underscore{}MEDIA CONNECT\underscore{}DEFERRED CONNECT\underscore{}INTERACTIVE CONNECT\underscore{}LOCALDRIVE CONNECT\underscore{}NEED\underscore{}DRIVE CONNECT\underscore{}PROMPT CONNECT\underscore{}REDIRECT CONNECT\underscore{}REFCOUNT CONNECT\underscore{}RESERVED CONNECT\underscore{}TEMPORARY CONNECT\underscore{}UPDATE\underscore{}PROFILE CONNECT\underscore{}UPDATE\underscore{}RECENT CONNDLG\underscore{}CONN\underscore{}POINT CONNDLG\underscore{}HIDE\underscore{}BOX CONNDLG\underscore{}NOT\underscore{}PERSIST CONNDLG\underscore{}PERSIST CONNDLG\underscore{}RO\underscore{}PATH CONNDLG\underscore{}USE\underscore{}MRU CONNECT\underscore{}UPDATE\underscore{}PROFILE DEF\underscore{}MAX\underscore{}PWHIST DACL\underscore{}SECURITY\underscore{}INFORMATION DISC\underscore{}NO\underscore{}FORCE DISC\underscore{}UPDATE\underscore{}PROFILE DFS\underscore{}ADD\underscore{}VOLUME DFS\underscore{}RESTORE\underscore{}VOLUME DFS\underscore{}STORAGE\underscore{}STATE\underscore{}ACTIVE DFS\underscore{}STORAGE\underscore{}STATE\underscore{}OFFLINE DFS\underscore{}STORAGE\underscore{}STATE\underscore{}ONLINE DFS\underscore{}VOLUME\underscore{}STATE\underscore{}INCONSISTENT DFS\underscore{}VOLUME\underscore{}STATE\underscore{}OK DFS\underscore{}VOLUME\underscore{}STATE\underscore{}OFFLINE DFS\underscore{}VOLUME\underscore{}STATE\underscore{}ONLINE EVENTLOG\underscore{}BACKWARDS\underscore{}READ EVENTLOG\underscore{}FORWARDS\underscore{}READ EVENTLOG\underscore{}SEEK\underscore{}READ EVENTLOG\underscore{}SEQUENTIAL\underscore{}READ EVENTLOG\underscore{}ERROR\underscore{}TYPE EVENTLOG\underscore{}WARNING\underscore{}TYPE EVENTLOG\underscore{}INFORMATION\underscore{}TYPE EVENTLOG\underscore{}AUDIT\underscore{}SUCCESS EVENTLOG\underscore{}AUDIT\underscore{}FAILURE FILTER\underscore{}INTERDOMAIN\underscore{}TRUST\underscore{}ACCOUNT FILTER\underscore{}NORMAL\underscore{}ACCOUNT FILTER\underscore{}SERVER\underscore{}TRUST\underscore{}ACCOUNT FILTER\underscore{}TEMP\underscore{}DUPLICATE\underscore{}ACCOUNT FILTER\underscore{}WORKSTATION\underscore{}TRUST\underscore{}ACCOUNT GROUP\underscore{}SECURITY\underscore{}INFORMATION IDASYNC IDTIMEOUT Interactive JOB\underscore{}ADD\underscore{}CURRENT\underscore{}DATE JOB\underscore{}EXEC\underscore{}ERROR JOB\underscore{}INPUT\underscore{}FLAGS JOB\underscore{}NONINTERACTIVE JOB\underscore{}OUTPUT\underscore{}FLAGS JOB\underscore{}RUN\underscore{}PERIODICALLY JOB\underscore{}RUNS\underscore{}TODAY KERB\underscore{}CHECKSUM\underscore{}CRC32 KERB\underscore{}CHECKSUM\underscore{}DES\underscore{}MAC KERB\underscore{}CHECKSUM\underscore{}DES\underscore{}MAC\underscore{}MD5 KERB\underscore{}CHECKSUM\underscore{}HMAC\underscore{}MD5 KERB\underscore{}CHECKSUM\underscore{}KRB\underscore{}DES\underscore{}MAC KERB\underscore{}CHECKSUM\underscore{}LM KERB\underscore{}CHECKSUM\underscore{}MD25 KERB\underscore{}CHECKSUM\underscore{}MD4 KERB\underscore{}CHECKSUM\underscore{}MD5 KERB\underscore{}CHECKSUM\underscore{}MD5\underscore{}DES KERB\underscore{}CHECKSUM\underscore{}MD5\underscore{}HMAC KERB\underscore{}CHECKSUM\underscore{}NONE KERB\underscore{}CHECKSUM\underscore{}RC4\underscore{}MD5 KERB\underscore{}CHECKSUM\underscore{}REAL\underscore{}CRC32 KERB\underscore{}CHECKSUM\underscore{}SHA1 KERB\underscore{}DECRYPT\underscore{}FLAG\underscore{}DEFAULT\underscore{}KEY KERB\underscore{}ETYPE\underscore{}DES\underscore{}CBC\underscore{}CRC KERB\underscore{}ETYPE\underscore{}DES\underscore{}CBC\underscore{}MD4 KERB\underscore{}ETYPE\underscore{}DES\underscore{}CBC\underscore{}MD5 KERB\underscore{}ETYPE\underscore{}DES\underscore{}CBC\underscore{}MD5\underscore{}NT KERB\underscore{}ETYPE\underscore{}DES\underscore{}PLAIN KERB\underscore{}ETYPE\underscore{}DSA\underscore{}SIGN KERB\underscore{}ETYPE\underscore{}NULL KERB\underscore{}ETYPE\underscore{}PKCS7\underscore{}PUB KERB\underscore{}ETYPE\underscore{}RC4\underscore{}HMAC\underscore{}NT KERB\underscore{}ETYPE\underscore{}RC4\underscore{}HMAC\underscore{}NT\underscore{}EXP KERB\underscore{}ETYPE\underscore{}RC4\underscore{}HMAC\underscore{}OLD KERB\underscore{}ETYPE\underscore{}RC4\underscore{}HMAC\underscore{}OLD\underscore{}EXP KERB\underscore{}ETYPE\underscore{}RC4\underscore{}LM KERB\underscore{}ETYPE\underscore{}RC4\underscore{}MD4 KERB\underscore{}ETYPE\underscore{}RC4\underscore{}PLAIN KERB\underscore{}ETYPE\underscore{}RC4\underscore{}PLAIN\underscore{}EXP KERB\underscore{}ETYPE\underscore{}RC4\underscore{}PLAIN\underscore{}OLD KERB\underscore{}ETYPE\underscore{}RC4\underscore{}PLAIN\underscore{}OLD\underscore{}EXP KERB\underscore{}ETYPE\underscore{}RC4\underscore{}PLAIN2 KERB\underscore{}ETYPE\underscore{}RC4\underscore{}SHA KERB\underscore{}ETYPE\underscore{}RSA\underscore{}PRIV KERB\underscore{}ETYPE\underscore{}RSA\underscore{}PUB KERB\underscore{}ETYPE\underscore{}RSA\underscore{}PUB\underscore{}MD5 KERB\underscore{}ETYPE\underscore{}RSA\underscore{}PUB\underscore{}SHA1 KERB\underscore{}RETRIEVE\underscore{}TICKET\underscore{}DONT\underscore{}USE\underscore{}CACHE KERB\underscore{}RETRIEVE\underscore{}TICKET\underscore{}USE\underscore{}CACHE\underscore{}ONLY KERB\underscore{}WRAP\underscore{}NO\underscore{}ENCRYPT KERBEROS\underscore{}REVISION KERBEROS\underscore{}VERSION KerbInteractiveLogon KerbSmartCardLogon KerbInteractiveProfile KerbSmartCardProfile LG\underscore{}INCLUDE\underscore{}INDIRECT LOGON\underscore{}CACHED\underscore{}ACCOUNT LOGON\underscore{}EXTRA\underscore{}SIDS LOGON\underscore{}GRACE\underscore{}LOGON LOGON\underscore{}GUEST LOGON\underscore{}NOENCRYPTION LOGON\underscore{}PROFILE\underscore{}PATH\underscore{}RETURNED LOGON\underscore{}RESOURCE\underscore{}GROUPS LOGON\underscore{}SERVER\underscore{}TRUST\underscore{}ACCOUNT LOGON\underscore{}SUBAUTH\underscore{}SESSION\underscore{}KEY LOGON\underscore{}USED\underscore{}LM\underscore{}PASSWORD LSA\underscore{}MODE\underscore{}INDIVIDUAL\underscore{}ACCOUNTS LSA\underscore{}MODE\underscore{}LOG\underscore{}FULL LSA\underscore{}MODE\underscore{}MANDATORY\underscore{}ACCESS LSA\underscore{}MODE\underscore{}PASSWORD\underscore{}PROTECTED MAJOR\underscore{}VERSION\underscore{}MASK MsV1\underscore{}0InteractiveLogon MsV1\underscore{}0Lm20Logon MsV1\underscore{}0NetworkLogon MsV1\underscore{}0SubAuthLogon MsV1\underscore{}0InteractiveProfile MsV1\underscore{}0Lm20LogonProfile MsV1\underscore{}0SmartCardProfile MsV1\underscore{}0EnumerateUsers MsV1\underscore{}0CacheLogon MsV1\underscore{}0CacheLookup MsV1\underscore{}0ChangeCachedPassword MsV1\underscore{}0ChangePassword MsV1\underscore{}0DeriveCredential MsV1\underscore{}0GenericPassthrough MsV1\underscore{}0GetUserInfo MsV1\underscore{}0Lm20ChallengeRequest MsV1\underscore{}0Lm20GetChallengeResponse MsV1\underscore{}0ReLogonUsers MsV1\underscore{}0SubAuth MSV1\underscore{}0\underscore{}CHALLENGE\underscore{}LENGTH MSV1\underscore{}0\underscore{}USER\underscore{}SESSION\underscore{}KEY\underscore{}LENGTH MSV1\underscore{}0\underscore{}LANMAN\underscore{}SESSION\underscore{}KEY\underscore{}LENGTH MSV1\underscore{}0\underscore{}ALLOW\underscore{}SERVER\underscore{}TRUST\underscore{}ACCOUNT MSV1\underscore{}0\underscore{}ALLOW\underscore{}WORKSTATION\underscore{}TRUST\underscore{}ACCOUNT MSV1\underscore{}0\underscore{}CLEARTEXT\underscore{}PASSWORD\underscore{}ALLOWED MSV1\underscore{}0\underscore{}DERIVECRED\underscore{}TYPE\underscore{}SHA1 MSV1\underscore{}0\underscore{}DONT\underscore{}TRY\underscore{}GUEST\underscore{}ACCOUNT MSV1\underscore{}0\underscore{}RETURN\underscore{}PASSWORD\underscore{}EXPIRY MSV1\underscore{}0\underscore{}RETURN\underscore{}PROFILE\underscore{}PATH MSV1\underscore{}0\underscore{}RETURN\underscore{}USER\underscore{}PARAMETERS MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}DLL\underscore{}EX MSV1\underscore{}0\underscore{}TRY\underscore{}GUEST\underscore{}ACCOUNT\underscore{}ONLY MSV1\underscore{}0\underscore{}TRY\underscore{}SPECIFIED\underscore{}DOMAIN\underscore{}ONLY MSV1\underscore{}0\underscore{}UPDATE\underscore{}LOGON\underscore{}STATISTICS MSV1\underscore{}0\underscore{}MNS\underscore{}LOGON MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}DLL MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}DLL\underscore{}SHIFT MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}DLL\underscore{}IIS MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}DLL\underscore{}RAS MSV1\underscore{}0\underscore{}SUBAUTHENTICATION\underscore{}FLAGS MSV1\underscore{}0\underscore{}CRED\underscore{}LM\underscore{}PRESENT MSV1\underscore{}0\underscore{}CRED\underscore{}NT\underscore{}PRESENT MSV1\underscore{}0\underscore{}CRED\underscore{}VERSION MSV1\underscore{}0\underscore{}OWF\underscore{}PASSWORD\underscore{}LENGTH MSV1\underscore{}0\underscore{}NTLM3\underscore{}OWF\underscore{}LENGTH MSV1\underscore{}0\underscore{}NTLM3\underscore{}RESPONSE\underscore{}LENGTH MSV1\underscore{}0\underscore{}MAX\underscore{}AVL\underscore{}SIZE MSV1\underscore{}0\underscore{}MAX\underscore{}NTLM3\underscore{}LIFE MSV1\underscore{}0\underscore{}NTLM3\underscore{}INPUT\underscore{}LENGTH MsvAvEOL MsvAvNbComputerName MsvAvNbDomainName MsvAvDnsDomainName MsvAvDnsServerName NegCallPackageMax NegEnumPackagePrefixes NEGOTIATE\underscore{}MAX\underscore{}PREFIX NETLOGON\underscore{}CONTROL\underscore{}BACKUP\underscore{}CHANGE\underscore{}LOG NETLOGON\underscore{}CONTROL\underscore{}BREAKPOINT NETLOGON\underscore{}CONTROL\underscore{}FIND\underscore{}USER NETLOGON\underscore{}CONTROL\underscore{}PDC\underscore{}REPLICATE NETLOGON\underscore{}CONTROL\underscore{}QUERY NETLOGON\underscore{}CONTROL\underscore{}REDISCOVER NETLOGON\underscore{}CONTROL\underscore{}REPLICATE NETLOGON\underscore{}CONTROL\underscore{}SET\underscore{}DBFLAG NETLOGON\underscore{}CONTROL\underscore{}SYNCHRONIZE NETLOGON\underscore{}CONTROL\underscore{}TC\underscore{}QUERY NETLOGON\underscore{}CONTROL\underscore{}TRANSPORT\underscore{}NOTIFY NETLOGON\underscore{}CONTROL\underscore{}TRUNCATE\underscore{}LOG NETLOGON\underscore{}CONTROL\underscore{}UNLOAD\underscore{}NETLOGON\underscore{}DLL NETLOGON\underscore{}FULL\underscore{}SYNC\underscore{}REPLICATION NETLOGON\underscore{}REDO\underscore{}NEEDED NETLOGON\underscore{}REPLICATION\underscore{}IN\underscore{}PROGRESS NETLOGON\underscore{}REPLICATION\underscore{}NEEDED NetSetupDnsMachine NetSetupDomain NetSetupDomainName NetSetupMachine NetSetupNonExistentDomain NetSetupUnjoined NetSetupUnknown NetSetupUnknownStatus NetSetupWorkgroup NetSetupWorkgroupName NETSETUP\underscore{}ACCT\underscore{}CREATE NETSETUP\underscore{}ACCT\underscore{}DELETE NETSETUP\underscore{}DOMAIN\underscore{}JOIN\underscore{}IF\underscore{}JOINED NETSETUP\underscore{}INSTALL\underscore{}INVOCATION NETSETUP\underscore{}JOIN\underscore{}DOMAIN NETSETUP\underscore{}JOIN\underscore{}UNSECURE NETSETUP\underscore{}WIN9X\underscore{}UPGRADE NETPROPERTY\underscore{}PERSISTENT Network NO\underscore{}PERMISSION\underscore{}REQUIRED ONE\underscore{}DAY OWNER\underscore{}SECURITY\underscore{}INFORMATION PERM\underscore{}FILE\underscore{}CREATE PERM\underscore{}FILE\underscore{}READ PERM\underscore{}FILE\underscore{}WRITE POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}FAILURE POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}MASK POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}SUCCESS POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}UNCHANGED POLICY\underscore{}ALL\underscore{}ACCESS POLICY\underscore{}AUDIT\underscore{}LOG\underscore{}ADMIN POLICY\underscore{}CREATE\underscore{}ACCOUNT POLICY\underscore{}CREATE\underscore{}PRIVILEGE POLICY\underscore{}CREATE\underscore{}SECRET POLICY\underscore{}EXECUTE POLICY\underscore{}GET\underscore{}PRIVATE\underscore{}INFORMATION POLICY\underscore{}LOOKUP\underscore{}NAMES POLICY\underscore{}NOTIFICATION POLICY\underscore{}READ POLICY\underscore{}SERVER\underscore{}ADMIN POLICY\underscore{}SET\underscore{}AUDIT\underscore{}REQUIREMENTS POLICY\underscore{}SET\underscore{}DEFAULT\underscore{}QUOTA\underscore{}LIMITS POLICY\underscore{}TRUST\underscore{}ADMIN POLICY\underscore{}VIEW\underscore{}AUDIT\underscore{}INFORMATION POLICY\underscore{}VIEW\underscore{}LOCAL\underscore{}INFORMATION POLICY\underscore{}WRITE POLICY\underscore{}QOS\underscore{}ALLOW\underscore{}LOCAL\underscore{}ROOT\underscore{}CERT\underscore{}STORE POLICY\underscore{}QOS\underscore{}DHCP\underscore{}SERVER\underscore{}ALLOWED POLICY\underscore{}QOS\underscore{}INBOUND\underscore{}CONFIDENTIALITY POLICY\underscore{}QOS\underscore{}INBOUND\underscore{}INTEGRITY POLICY\underscore{}QOS\underscore{}OUTBOUND\underscore{}CONFIDENTIALITY POLICY\underscore{}QOS\underscore{}OUTBOUND\underscore{}INTEGRITY POLICY\underscore{}QOS\underscore{}RAS\underscore{}SERVER\underscore{}ALLOWED POLICY\underscore{}QOS\underscore{}SCHANNEL\underscore{}REQUIRED PolicyAccountDomainInformation PolicyAuditEventsInformation PolicyAuditFullQueryInformation PolicyAuditFullSetInformation PolicyAuditLogInformation PolicyDefaultQuotaInformation PolicyDnsDomainInformation PolicyLsaServerRoleInformation PolicyModificationInformation PolicyPdAccountInformation PolicyPrimaryDomainInformation PolicyReplicaSourceInformation PolicyDomainEfsInformation PolicyDomainKerberosTicketInformation PolicyDomainQualityOfServiceInformation PolicyNotifyAccountDomainInformation PolicyNotifyAuditEventsInformation PolicyNotifyDnsDomainInformation PolicyNotifyDomainEfsInformation PolicyNotifyDomainKerberosTicketInformation PolicyNotifyMachineAccountPasswordInformation PolicyNotifyServerRoleInformation PolicyServerDisabled PolicyServerEnabled PolicyServerRoleBackup PolicyServerRolePrimary Proxy REMOTE\underscore{}NAME\underscore{}INFO\underscore{}LEVEL REPL\underscore{}EXTENT\underscore{}FILE REPL\underscore{}EXTENT\underscore{}TREE REPL\underscore{}INTEGRITY\underscore{}TREE REPL\underscore{}INTEGRITY\underscore{}FILE REPL\underscore{}ROLE\underscore{}BOTH REPL\underscore{}ROLE\underscore{}EXPORT REPL\underscore{}ROLE\underscore{}IMPORT REPL\underscore{}STATE\underscore{}OK REPL\underscore{}STATE\underscore{}NO\underscore{}MASTER REPL\underscore{}STATE\underscore{}NO\underscore{}SYNC REPL\underscore{}STATE\underscore{}NEVER\underscore{}REPLICATED REPL\underscore{}UNLOCK\underscore{}FORCE REPL\underscore{}UNLOCK\underscore{}NOFORCE RESOURCEUSAGE\underscore{}ALL RESOURCE\underscore{}CONNECTED RESOURCE\underscore{}CONTEXT RESOURCE\underscore{}GLOBALNET RESOURCE\underscore{}REMEMBERED RESOURCETYPE\underscore{}RESERVED RESOURCETYPE\underscore{}UNKNOWN RESOURCETYPE\underscore{}ANY RESOURCETYPE\underscore{}DISK RESOURCETYPE\underscore{}PRINT RESOURCEDISPLAYTYPE\underscore{}DIRECTORY RESOURCEDISPLAYTYPE\underscore{}DOMAIN RESOURCEDISPLAYTYPE\underscore{}FILE RESOURCEDISPLAYTYPE\underscore{}GENERIC RESOURCEDISPLAYTYPE\underscore{}GROUP RESOURCEDISPLAYTYPE\underscore{}NDSCONTAINER RESOURCEDISPLAYTYPE\underscore{}NETWORK RESOURCEDISPLAYTYPE\underscore{}ROOT RESOURCEDISPLAYTYPE\underscore{}SERVER RESOURCEDISPLAYTYPE\underscore{}SHARE RESOURCEDISPLAYTYPE\underscore{}SHAREADMIN RESOURCEDISPLAYTYPE\underscore{}TREE RESOURCEUSAGE\underscore{}ALL RESOURCEUSAGE\underscore{}CONNECTABLE RESOURCEUSAGE\underscore{}CONTAINER RESOURCEUSAGE\underscore{}ATTACHED RESOURCEUSAGE\underscore{}NOLOCALDEVICE RESOURCEUSAGE\underscore{}RESERVED RESOURCEUSAGE\underscore{}SIBLING SACL\underscore{}SECURITY\underscore{}INFORMATION SE\underscore{}GROUP\underscore{}ENABLED\underscore{}BY\underscore{}DEFAULT SE\underscore{}GROUP\underscore{}MANDATORY SE\underscore{}GROUP\underscore{}OWNER SE\underscore{}CREATE\underscore{}TOKEN\underscore{}NAME SE\underscore{}ASSIGNPRIMARYTOKEN\underscore{}NAME SE\underscore{}LOCK\underscore{}MEMORY\underscore{}NAME SE\underscore{}INCREASE\underscore{}QUOTA\underscore{}NAME SE\underscore{}UNSOLICITED\underscore{}INPUT\underscore{}NAME SE\underscore{}MACHINE\underscore{}ACCOUNT\underscore{}NAME SE\underscore{}TCB\underscore{}NAME SE\underscore{}SECURITY\underscore{}NAME SE\underscore{}TAKE\underscore{}OWNERSHIP\underscore{}NAME SE\underscore{}LOAD\underscore{}DRIVER\underscore{}NAME SE\underscore{}SYSTEM\underscore{}PROFILE\underscore{}NAME SE\underscore{}SYSTEMTIME\underscore{}NAME SE\underscore{}PROF\underscore{}SINGLE\underscore{}PROCESS\underscore{}NAME SE\underscore{}INC\underscore{}BASE\underscore{}PRIORITY\underscore{}NAME SE\underscore{}CREATE\underscore{}PAGEFILE\underscore{}NAME SE\underscore{}CREATE\underscore{}PERMANENT\underscore{}NAME SE\underscore{}BACKUP\underscore{}NAME SE\underscore{}RESTORE\underscore{}NAME SE\underscore{}SHUTDOWN\underscore{}NAME SE\underscore{}DEBUG\underscore{}NAME SE\underscore{}AUDIT\underscore{}NAME SE\underscore{}SYSTEM\underscore{}ENVIRONMENT\underscore{}NAME SE\underscore{}CHANGE\underscore{}NOTIFY\underscore{}NAME SE\underscore{}REMOTE\underscore{}SHUTDOWN\underscore{}NAME SE\underscore{}INTERACTIVE\underscore{}LOGON\underscore{}NAME SE\underscore{}DENY\underscore{}INTERACTIVE\underscore{}LOGON\underscore{}NAME SE\underscore{}NETWORK\underscore{}LOGON\underscore{}NAME SE\underscore{}DENY\underscore{}NETWORK\underscore{}LOGON\underscore{}NAME SE\underscore{}BATCH\underscore{}LOGON\underscore{}NAME SE\underscore{}DENY\underscore{}BATCH\underscore{}LOGON\underscore{}NAME SE\underscore{}SERVICE\underscore{}LOGON\underscore{}NAME SE\underscore{}DENY\underscore{}SERVICE\underscore{}LOGON\underscore{}NAME Service SC\underscore{}ACTION\underscore{}NONE SC\underscore{}ACTION\underscore{}REBOOT SC\underscore{}ACTION\underscore{}RESTART SC\underscore{}ACTION\underscore{}RUN\underscore{}COMMAND SC\underscore{}MANAGER\underscore{}ALL\underscore{}ACCESS SC\underscore{}MANAGER\underscore{}CONNECT SC\underscore{}MANAGER\underscore{}CREATE\underscore{}SERVICE SC\underscore{}MANAGER\underscore{}ENUMERATE\underscore{}SERVICE SC\underscore{}MANAGER\underscore{}LOCK SC\underscore{}MANAGER\underscore{}MODIFY\underscore{}BOOT\underscore{}CONFIG SC\underscore{}MANAGER\underscore{}QUERY\underscore{}LOCK\underscore{}STATUS SC\underscore{}STATUS\underscore{}PROCESS\underscore{}INFO SERVICE\underscore{}ACCEPT\underscore{}STOP SERVICE\underscore{}ACCEPT\underscore{}PAUSE\underscore{}CONTINUE SERVICE\underscore{}ACCEPT\underscore{}SHUTDOWN SERVICE\underscore{}ACCEPT\underscore{}PARAMCHANGE SERVICE\underscore{}ACCEPT\underscore{}NETBINDCHANGE SERVICE\underscore{}ACCEPT\underscore{}HARDWAREPROFILECHANGE SERVICE\underscore{}ACCEPT\underscore{}POWEREVENT SERVICE\underscore{}FILE\underscore{}SYSTEM\underscore{}DRIVER SERVICE\underscore{}INTERACTIVE\underscore{}PROCESS SERVICE\underscore{}KERNEL\underscore{}DRIVER SERVICE\underscore{}WIN32\underscore{}OWN\underscore{}PROCESS SERVICE\underscore{}WIN32\underscore{}SHARE\underscore{}PROCESS SERVICE\underscore{}AUTO\underscore{}START SERVICE\underscore{}BOOT\underscore{}START SERVICE\underscore{}DEMAND\underscore{}START SERVICE\underscore{}DISABLED SERVICE\underscore{}SYSTEM\underscore{}START SERVICE\underscore{}ERROR\underscore{}CRITICAL SERVICE\underscore{}ERROR\underscore{}IGNORE SERVICE\underscore{}ERROR\underscore{}NORMAL SERVICE\underscore{}ERROR\underscore{}SEVERE SERVICE\underscore{}CONTINUE\underscore{}PENDING SERVICE\underscore{}PAUSE\underscore{}PENDING SERVICE\underscore{}PAUSED SERVICE\underscore{}RUNNING SERVICE\underscore{}START\underscore{}PENDING SERVICE\underscore{}STOPPED SERVICE\underscore{}STOP\underscore{}PENDING SERVICE\underscore{}ALL\underscore{}ACCESS SERVICE\underscore{}CHANGE\underscore{}CONFIG SERVICE\underscore{}ENUMERATE\underscore{}DEPENDENTS SERVICE\underscore{}INTERROGATE SERVICE\underscore{}PAUSE\underscore{}CONTINUE SERVICE\underscore{}QUERY\underscore{}CONFIG SERVICE\underscore{}QUERY\underscore{}STATUS SERVICE\underscore{}START SERVICE\underscore{}STOP SERVICE\underscore{}USER\underscore{}DEFINED\underscore{}CONTROL SERVICE\underscore{}RUNS\underscore{}IN\underscore{}SYSTEM\underscore{}PROCESS SERVICE\underscore{}CONTROL\underscore{}CONTINUE SERVICE\underscore{}CONTROL\underscore{}DEVICEEVENT SERVICE\underscore{}CONTROL\underscore{}HARDWAREPROFILECHANGE SERVICE\underscore{}CONTROL\underscore{}INTERROGATE SERVICE\underscore{}CONTROL\underscore{}NETBINDADD SERVICE\underscore{}CONTROL\underscore{}NETBINDDISABLE SERVICE\underscore{}CONTROL\underscore{}NETBINDENABLE SERVICE\underscore{}CONTROL\underscore{}NETBINDREMOVE SERVICE\underscore{}CONTROL\underscore{}PAUSE SERVICE\underscore{}CONTROL\underscore{}PARAMCHANGE SERVICE\underscore{}CONTROL\underscore{}POWEREVENT SERVICE\underscore{}CONTROL\underscore{}SHUTDOWN SERVICE\underscore{}CONTROL\underscore{}STOP SERVICE\underscore{}CONFIG\underscore{}FAILURE\underscore{}ACTIONS SERVICE\underscore{}NO\underscore{}CHANGE SERVICE\underscore{}ACTIVE SERVICE\underscore{}DRIVER SERVICE\underscore{}INACTIVE SERVICE\underscore{}STATE\underscore{}ALL SERVICE\underscore{}WIN32 STYPE\underscore{}DEVICE STYPE\underscore{}DISKTREE STYPE\underscore{}IPC STYPE\underscore{}PRINTQ SUPPORTS\underscore{}ANY SUPPORTS\underscore{}LOCAL SUPPORTS\underscore{}REMOTE\underscore{}ADMIN\underscore{}PROTOCOL SUPPORTS\underscore{}RPC SUPPORTS\underscore{}SAM\underscore{}PROTOCOL SUPPORTS\underscore{}UNICODE SV\underscore{}HIDDEN SV\underscore{}MAX\underscore{}CMD\underscore{}LEN SV\underscore{}MAX\underscore{}SRV\underscore{}HEUR\underscore{}LEN SV\underscore{}NODISC SV\underscore{}PLATFORM\underscore{}ID\underscore{}OS2 SV\underscore{}PLATFORM\underscore{}ID\underscore{}NT SV\underscore{}SHARESECURITY SV\underscore{}TYPE\underscore{}AFP SV\underscore{}TYPE\underscore{}ALL SV\underscore{}TYPE\underscore{}ALTERNATE\underscore{}XPORT SV\underscore{}TYPE\underscore{}BACKUP\underscore{}BROWSER SV\underscore{}TYPE\underscore{}CLUSTER\underscore{}NT SV\underscore{}TYPE\underscore{}DCE SV\underscore{}TYPE\underscore{}DFS SV\underscore{}TYPE\underscore{}DIALIN\underscore{}SERVER SV\underscore{}TYPE\underscore{}DOMAIN\underscore{}BAKCTRL SV\underscore{}TYPE\underscore{}DOMAIN\underscore{}CTRL SV\underscore{}TYPE\underscore{}DOMAIN\underscore{}ENUM SV\underscore{}TYPE\underscore{}DOMAIN\underscore{}MASTER SV\underscore{}TYPE\underscore{}DOMAIN\underscore{}MEMBER SV\underscore{}TYPE\underscore{}LOCAL\underscore{}LIST\underscore{}ONLY SV\underscore{}TYPE\underscore{}MASTER\underscore{}BROWSER SV\underscore{}TYPE\underscore{}NOVELL SV\underscore{}TYPE\underscore{}NT SV\underscore{}TYPE\underscore{}POTENTIAL\underscore{}BROWSER SV\underscore{}TYPE\underscore{}PRINTQ\underscore{}SERVER SV\underscore{}TYPE\underscore{}SERVER SV\underscore{}TYPE\underscore{}SERVER\underscore{}MFPN SV\underscore{}TYPE\underscore{}SERVER\underscore{}NT SV\underscore{}TYPE\underscore{}SERVER\underscore{}OSF SV\underscore{}TYPE\underscore{}SERVER\underscore{}UNIX SV\underscore{}TYPE\underscore{}SERVER\underscore{}VMS SV\underscore{}TYPE\underscore{}SQLSERVER SV\underscore{}TYPE\underscore{}TERMINALSERVER SV\underscore{}TYPE\underscore{}TIME\underscore{}SOURCE SV\underscore{}TYPE\underscore{}WFW SV\underscore{}TYPE\underscore{}WINDOWS SV\underscore{}TYPE\underscore{}WORKSTATION SV\underscore{}TYPE\underscore{}XENIX\underscore{}SERVER SV\underscore{}USERS\underscore{}PER\underscore{}LICENSE SV\underscore{}USERSECURITY SV\underscore{}VISIBLE SW\underscore{}AUTOPROF\underscore{}LOAD\underscore{}MASK SW\underscore{}AUTOPROF\underscore{}SAVE\underscore{}MASK TIMEQ\underscore{}FOREVER TRUST\underscore{}ATTRIBUTE\underscore{}NON\underscore{}TRANSITIVE TRUST\underscore{}ATTRIBUTE\underscore{}TREE\underscore{}PARENT TRUST\underscore{}ATTRIBUTE\underscore{}TREE\underscore{}ROOT TRUST\underscore{}ATTRIBUTE\underscore{}UPLEVEL\underscore{}ONLY TRUST\underscore{}ATTRIBUTES\underscore{}USER TRUST\underscore{}ATTRIBUTES\underscore{}VALID TRUST\underscore{}AUTH\underscore{}TYPE\underscore{}CLEAR TRUST\underscore{}AUTH\underscore{}TYPE\underscore{}NONE TRUST\underscore{}AUTH\underscore{}TYPE\underscore{}NT4OWF TRUST\underscore{}AUTH\underscore{}TYPE\underscore{}VERSION TRUST\underscore{}DIRECTION\underscore{}BIDIRECTIONAL TRUST\underscore{}DIRECTION\underscore{}DISABLED TRUST\underscore{}DIRECTION\underscore{}INBOUND TRUST\underscore{}DIRECTION\underscore{}OUTBOUND TRUST\underscore{}TYPE\underscore{}DCE TRUST\underscore{}TYPE\underscore{}DOWNLEVEL TRUST\underscore{}TYPE\underscore{}MIT TRUST\underscore{}TYPE\underscore{}UPLEVEL TrustedControllersInformation TrustedDomainAuthInformation TrustedDomainFullInformation TrustedDomainInformationBasic TrustedDomainInformationEx TrustedDomainNameInformation TrustedPasswordInformation TrustedPosixOffsetInformation UAS\underscore{}ROLE\underscore{}STANDALONE UAS\underscore{}ROLE\underscore{}MEMBER UAS\underscore{}ROLE\underscore{}BACKUP UAS\underscore{}ROLE\underscore{}PRIMARY UF\underscore{}ACCOUNT\underscore{}TYPE\underscore{}MASK UF\underscore{}ACCOUNTDISABLE UF\underscore{}DONT\underscore{}EXPIRE\underscore{}PASSWD UF\underscore{}DONT\underscore{}REQUIRE\underscore{}PREAUTH UF\underscore{}ENCRYPTED\underscore{}TEXT\underscore{}PASSWORD\underscore{}ALLOWED UF\underscore{}HOMEDIR\underscore{}REQUIRED UF\underscore{}INTERDOMAIN\underscore{}TRUST\underscore{}ACCOUNT UF\underscore{}LOCKOUT UF\underscore{}MACHINE\underscore{}ACCOUNT\underscore{}MASK UF\underscore{}MNS\underscore{}LOGON\underscore{}ACCOUNT UF\underscore{}NORMAL\underscore{}ACCOUNT UF\underscore{}NOT\underscore{}DELEGATED UF\underscore{}PASSWD\underscore{}CANT\underscore{}CHANGE UF\underscore{}PASSWD\underscore{}NOTREQD UF\underscore{}SCRIPT UF\underscore{}SERVER\underscore{}TRUST\underscore{}ACCOUNT UF\underscore{}SETTABLE\underscore{}BITS UF\underscore{}SMARTCARD\underscore{}REQUIRED UF\underscore{}TEMP\underscore{}DUPLICATE\underscore{}ACCOUNT UF\underscore{}TRUSTED\underscore{}FOR\underscore{}DELEGATION UF\underscore{}USE\underscore{}DES\underscore{}KEY\underscore{}ONLY UF\underscore{}WORKSTATION\underscore{}TRUST\underscore{}ACCOUNT UNITS\underscore{}PER\underscore{}WEEK UNIVERSAL\underscore{}NAME\underscore{}INFO\underscore{}LEVEL Unlock USE\underscore{}FORCE USE\underscore{}LOTS\underscore{}OF\underscore{}FORCE USE\underscore{}NOFORCE USE\underscore{}SPECIFIC\underscore{}TRANSPORT USE\underscore{}CHARDEV USE\underscore{}CONN USE\underscore{}DISCONN USE\underscore{}DISKDEV USE\underscore{}IPC USE\underscore{}NETERR USE\underscore{}OK USE\underscore{}PAUSED USE\underscore{}RECONN USE\underscore{}SESSLOST USE\underscore{}SPOOLDEV USE\underscore{}WILDCARD USER\underscore{}MAXSTORAGE\underscore{}UNLIMITED USER\underscore{}PRIV\underscore{}ADMIN USER\underscore{}PRIV\underscore{}GUEST USER\underscore{}PRIV\underscore{}USER WNCON\underscore{}DYNAMIC WNCON\underscore{}FORNETCARD WNCON\underscore{}NOTROUTED WNCON\underscore{}SLOWLINK WNNC\underscore{}CRED\underscore{}MANAGER WNNC\underscore{}NET\underscore{}10NET WNNC\underscore{}NET\underscore{}3IN1 WNNC\underscore{}NET\underscore{}9TILES WNNC\underscore{}NET\underscore{}APPLETALK WNNC\underscore{}NET\underscore{}AS400 WNNC\underscore{}NET\underscore{}AVID WNNC\underscore{}NET\underscore{}BMC WNNC\underscore{}NET\underscore{}BWNFS WNNC\underscore{}NET\underscore{}CLEARCASE WNNC\underscore{}NET\underscore{}COGENT WNNC\underscore{}NET\underscore{}CSC WNNC\underscore{}NET\underscore{}DCE WNNC\underscore{}NET\underscore{}DECORB WNNC\underscore{}NET\underscore{}DISTINCT WNNC\underscore{}NET\underscore{}DOCUSPACE WNNC\underscore{}NET\underscore{}EXTENDNET WNNC\underscore{}NET\underscore{}FARALLON WNNC\underscore{}NET\underscore{}FJ\underscore{}REDIR WNNC\underscore{}NET\underscore{}FTP\underscore{}NFS WNNC\underscore{}NET\underscore{}FRONTIER WNNC\underscore{}NET\underscore{}HOB\underscore{}NFS WNNC\underscore{}NET\underscore{}IBMAL WNNC\underscore{}NET\underscore{}INTERGRAPH WNNC\underscore{}NET\underscore{}LANMAN WNNC\underscore{}NET\underscore{}LANTASTIC WNNC\underscore{}NET\underscore{}LANSTEP WNNC\underscore{}NET\underscore{}LIFENET WNNC\underscore{}NET\underscore{}LOCUS WNNC\underscore{}NET\underscore{}MANGOSOFT WNNC\underscore{}NET\underscore{}MASFAX WNNC\underscore{}NET\underscore{}MSNET WNNC\underscore{}NET\underscore{}NETWARE WNNC\underscore{}NET\underscore{}OBJECT\underscore{}DIRE WNNC\underscore{}NET\underscore{}PATHWORKS WNNC\underscore{}NET\underscore{}POWERLAN WNNC\underscore{}NET\underscore{}PROTSTOR WNNC\underscore{}NET\underscore{}RDR2SAMPLE WNNC\underscore{}NET\underscore{}SERNET WNNC\underscore{}NET\underscore{}SHIVA WNNC\underscore{}NET\underscore{}SUN\underscore{}PC\underscore{}NFS WNNC\underscore{}NET\underscore{}SYMFONET WNNC\underscore{}NET\underscore{}TWINS WNNC\underscore{}NET\underscore{}VINES WTS\underscore{}CURRENT\underscore{}SERVER WTS\underscore{}CURRENT\underscore{}SERVER\underscore{}HANDLE WTS\underscore{}CURRENT\underscore{}SERVER\underscore{}NAME WTS\underscore{}CURRENT\underscore{}SESSION WTS\underscore{}EVENT\underscore{}NONE WTS\underscore{}EVENT\underscore{}CREATE WTS\underscore{}EVENT\underscore{}DELETE WTS\underscore{}EVENT\underscore{}RENAME WTS\underscore{}EVENT\underscore{}CONNECT WTS\underscore{}EVENT\underscore{}DISCONNECT WTS\underscore{}EVENT\underscore{}LOGON WTS\underscore{}EVENT\underscore{}LOGOFF WTS\underscore{}EVENT\underscore{}STATECHANGE WTS\underscore{}EVENT\underscore{}LICENSE WTS\underscore{}EVENT\underscore{}ALL WTS\underscore{}EVENT\underscore{}FLUSH WTS\underscore{}WSD\underscore{}FASTREBOOT WTS\underscore{}WSD\underscore{}LOGOFF WTS\underscore{}WSD\underscore{}POWEROFF WTS\underscore{}WSD\underscore{}REBOOT WTS\underscore{}WSD\underscore{}SHUTDOWN WTSActive WTSConnected WTSConnectQuery WTSShadow WTSDisconnected WTSIdle WTSListen WTSReset WTSDown WTSInit WTSApplicationName WTSClientAddress WTSClientBuildNumber WTSClientDirectory WTSClientDisplay WTSClientHardwareId WTSClientName WTSClientProductId WTSConnectState WTSDomainName WTSInitialProgram WTSOEMId WTSSessionId WTSUserName WTSWinStationName WTSWorkingDirectory WTSUserConfigInitialProgram WTSUserConfigWorkingDirectory WTSUserConfigfInheritInitialProgram WTSUserConfigfAllowLogonTerminalServer WTSUserConfigTimeoutSettingsConnections WTSUserConfigTimeoutSettingsDisconnections WTSUserConfigTimeoutSettingsIdle WTSUserConfigfDeviceClientDrives WTSUserConfigfDeviceClientPrinters WTSUserConfigfDeviceClientDefaultPrinter WTSUserConfigBrokenTimeoutSettings WTSUserConfigReconnectSettings WTSUserConfigModemCallbackSettings WTSUserConfigModemCallbackPhoneNumber WTSUserConfigShadowingSettings WTSUserConfigTerminalServerProfilePath WTSUserConfigTerminalServerHomeDir WTSUserConfigTerminalServerHomeDirDrive WTSUserConfigfTerminalServerRemoteHomeDir =head2 Useful Hashes The following hashes are useful, since they group several associated codes form the platform sdk together, or provide description for the constants. For each hash we describe its use and mention some functions it may be used with. This is work in progress and should be finished by the next release. =over 4 =item Work In progress =item \%SV\underscore{}TYPES Descriptions of the various server types. Could be used with .... =item \%SERVICE\underscore{}STATES Could be used with =item \%SERVICE\underscore{}TYPES Could be used with ... =item \%WTS\underscore{}STATES =item \%SERVICE\underscore{}FAILURE\underscore{}ACTIONS Could be used with .... =item \%SERVICE\underscore{}CONTROL\underscore{}DESCRIPTIONS English descriptions of the service\underscore{}control constants. Could be used with .... =item \%SERVICE\underscore{}STATE\underscore{}DESCRIPTIONS =item \%SERVICE\underscore{}CONTROLS =item \%SERVICE\underscore{}START\underscore{}TYPES =item \%SERVICE\underscore{}ERROR\underscore{}TYPES =item \%SC\underscore{}FAILURE\underscore{}ACTIONS Used in ChangeServiceConfig2 and QueryServiceConfig2 =item \%SERVICE\underscore{}ACCEPTED\underscore{}CONTROLS =item \%NET\underscore{}INFO\underscore{}DESCRIPTION Used with NetUseDel, NetWkStaTransportDel, NetUseAdd , GetInfo and Enum with the flags parameter. English descriptions of the status flag (asg\underscore{}type) of a NetUseAdd =item \%NET\underscore{}STATUS\underscore{}DESCRIPTION English descriptions of the status flag of a NetUseEnum or NetUseGetInfo call =item \%PRIVILEGE\underscore{}NAMES A list of privileges which can be set or used when querying. These apply to the functions in the the section on {\em Policy and Privileges (LSA)\/} section. =back =head1 FUNCTIONS {\tt I\char`\_NetLogonControl} --- {\tt I\char`\_NetLogonControl2} --- {\tt LogonControlQuery} --- {\tt LogonControlReplicate} --- {\tt LogonControlSynchronize} --- {\tt LogonControlPdcReplicate} --- {\tt LogonControlRediscover} --- {\tt LogonControlTCQuery} --- {\tt LogonControlTransportNotify} --- {\tt LogonControlFindUser} --- {\tt NetEnumerateTrustedDomains} --- {\tt I\char`\_NetGetDCList} {\tt LsaQueryInformationPolicy} --- {\tt LsaSetInformationPolicy} --- {\tt LsaQueryAuditLogPolicy} --- {\tt LsaQueryAuditEventsPolicy} --- {\tt LsaSetAuditEventsPolicy} --- {\tt LsaQueryPrimaryDomainPolicy} --- {\tt LsaSetPrimaryDomainPolicy} --- {\tt LsaQueryPdAccountPolicy} --- {\tt LsaQueryAccountDomainPolicy} --- {\tt LsaSetAccountDomainPolicy} --- {\tt LsaQueryServerRolePolicy} --- {\tt LsaSetServerRolePolicy} --- {\tt LsaQueryReplicaSourcePolicy} --- {\tt LsaSetReplicaSourcePolicy} --- {\tt LsaQueryDefaultQuotaPolicy} --- {\tt LsaSetDefaultQuotaPolicy} --- {\tt LsaQueryAuditFullPolicy} --- {\tt LsaSetAuditFullPolicy} --- {\tt LsaQueryDnsDomainPolicy} --- {\tt LsaSetDnsDomainPolicy} --- {\tt LsaQueryTrustedDomainInfo} --- {\tt LsaSetTrustedDomainInformation} --- {\tt LsaSetTrustedDomainInfo} --- {\tt LsaQueryTrustedDomainNameInfo} --- {\tt LsaSetTrustedDomainNameInfo} --- {\tt LsaQueryTrustedPosixOffsetInfo} --- {\tt LsaSetTrustedPosixOffsetInfo} --- {\tt LsaQueryTrustedPasswordInfo} --- {\tt LsaSetTrustedPasswordInfo} --- {\tt LsaRetrievePrivateData} --- {\tt LsaStorePrivateData} --- {\tt LsaEnumerateTrustedDomains} --- {\tt LsaLookupNames} --- {\tt LsaLookupSids} --- {\tt LsaEnumerateAccountsWithUserRight} --- {\tt LsaEnumerateAccountRights} --- {\tt LsaAddAccountRights} --- {\tt LsaRemoveAccountRights} {\tt GrantPrivilegeToAccount} --- {\tt RevokePrivilegeFromAccount} --- {\tt EnumAccountPrivileges} --- {\tt EnumPrivilegeAccounts} {\tt NetDfsAdd} --- {\tt NetDfsEnum} --- {\tt NetDfsGetInfo} --- {\tt NetDfsRemove} --- {\tt NetDfsSetInfo} --- {\tt NetDfsMove} --- {\tt NetDfsRename} --- {\tt NetDfsAddFtRoot} --- {\tt NetDfsRemoveFtRoot} --- {\tt NetDfsRemoveFtRootForced} --- {\tt NetDfsAddStdRoot} --- {\tt NetDfsAddStdRootForced} --- {\tt NetDfsRemoveStdRoot} --- {\tt NetDfsManagerInitialize} --- {\tt NetDfsGetClientInfo} --- {\tt NetDfsSetClientInfo} --- {\tt NetDfsGetDcAddress} {\tt NetGetJoinableOUs} --- {\tt NetGetJoinInformation} --- {\tt NetJoinDomain} --- {\tt NetRenameMachineInDomain} --- {\tt NetUnjoinDomain} --- {\tt NetValidateName} --- {\tt NetRegisterDomainNameChangeNotification} --- {\tt NetUnregisterDomainNameChangeNotification} {\tt NetFileClose} --- {\tt NetFileEnum} --- {\tt NetFileGetInfo} {\tt MultinetGetConnectionPerformance} --- {\tt NetGetAnyDCName} --- {\tt NetGetDCName} --- {\tt NetGetDisplayInformationIndex} --- {\tt NetQueryDisplayInformation} {\tt NetGroupAdd} --- {\tt NetGroupAddUser} --- {\tt NetGroupDel} --- {\tt NetGroupDelUser} --- {\tt NetGroupEnum} --- {\tt NetGroupGetInfo} --- {\tt NetGroupGetUsers} --- {\tt NetGroupSetInfo} --- {\tt NetGroupSetUsers} {\tt NetLocalGroupAdd} --- {\tt NetLocalGroupAddMember} --- {\tt NetLocalGroupAddMembers} --- {\tt NetLocalGroupAddMembersBySid} --- {\tt NetLocalGroupDel} --- {\tt NetLocalGroupDelMember} --- {\tt NetLocalGroupDelMembers} --- {\tt NetLocalGroupDelMembersBySid} --- {\tt NetLocalGroupEnum} --- {\tt NetLocalGroupGetInfo} --- {\tt NetLocalGroupGetMembers} --- {\tt NetLocalGroupSetInfo} --- {\tt NetLocalGroupSetMembers} --- {\tt NetLocalGroupSetMembersBySid} {\tt NetMessageBufferSend} --- {\tt NetMessageNameAdd} --- {\tt NetMessageNameDel} --- {\tt NetMessageNameEnum} --- {\tt NetMessageNameGetInfo} {\tt NetRemoteTOD} --- {\tt NetRemoteComputerSupports} {\tt NetReplExportDirAdd} --- {\tt NetReplExportDirDel} --- {\tt NetReplExportDirEnum} --- {\tt NetReplExportDirGetInfo} --- {\tt NetReplExportDirLock} --- {\tt NetReplExportDirSetInfo} --- {\tt NetReplExportDirUnlock} --- {\tt NetReplGetInfo} --- {\tt NetReplImportDirAdd} --- {\tt NetReplImportDirDel} --- {\tt NetReplImportDirEnum} --- {\tt NetReplImportDirGetInfo} --- {\tt NetReplImportDirLock} --- {\tt NetReplImportDirUnlock} --- {\tt NetReplSetInfo} {\tt NetScheduleJobAdd} --- {\tt NetScheduleJobDel} --- {\tt NetScheduleJobEnum} --- {\tt NetScheduleJobGetInfo} {\tt NetServerDiskEnum} --- {\tt NetServerEnum} --- {\tt NetServerGetInfo} --- {\tt NetServerSetInfo} --- {\tt NetServerTransportAdd} --- {\tt NetServerTransportDel} --- {\tt NetServerTransportEnum} {\tt NetSessionDel} --- {\tt NetSessionEnum} --- {\tt NetSessionGetInfo} {\tt NetStatisticsGet} {\tt NetShareAdd} --- {\tt NetShareCheck} --- {\tt NetShareDel} --- {\tt NetShareEnum} --- {\tt NetShareGetInfo} --- {\tt NetShareSetInfo} --- {\tt NetConnectionEnum} {\tt NetUserAdd} --- {\tt NetUserChangePassword} --- {\tt NetUserCheckPassword} --- {\tt NetUserDel} --- {\tt NetUserEnum} --- {\tt NetUserGetGroups} --- {\tt NetUserGetInfo} --- {\tt NetUserGetLocalGroups} --- {\tt NetUserSetGroups} --- {\tt NetUserSetInfo} --- {\tt NetUserSetProp} --- {\tt NetUserModalsGet} --- {\tt NetUserModalsSet} {\tt NetWkstaGetInfo} --- {\tt NetWkstaSetInfo} --- {\tt NetWkstaTransportAdd} --- {\tt NetWkstaTransportDel} --- {\tt NetWkstaTransportEnum} --- {\tt NetWkstaUserGetInfo} --- {\tt NetWkstaUserSetInfo} --- {\tt NetWkstaUserEnum} {\tt WNetAddConnection} --- {\tt WNetCancelConnection} --- {\tt WNetEnumResource} --- {\tt WNetConnectionDialog} --- {\tt WNetDisconnectDialog} --- {\tt WNetGetConnection} --- {\tt WNetGetNetworkInformation} --- {\tt WNetGetProviderName} --- {\tt WNetGetResourceInformation} --- {\tt WNetGetResourceParent} --- {\tt WNetGetUniversalName} --- {\tt WNetGetUser} --- {\tt WNetUseConnection} {\tt StartService} --- {\tt StopService} --- {\tt PauseService} --- {\tt ContinueService} --- {\tt InterrogateService} --- {\tt ControlService} --- {\tt CreateService} --- {\tt DeleteService} --- {\tt EnumServicesStatus} --- {\tt EnumDependentServices} --- {\tt ChangeServiceConfig} --- {\tt GetServiceDisplayName} --- {\tt GetServiceKeyName} --- {\tt LockServiceDatabase} --- {\tt UnlockServiceDatabase} --- {\tt QueryServiceLockStatus} --- {\tt QueryServiceConfig} --- {\tt QueryServiceStatus} --- {\tt QueryServiceObjectSecurity} --- {\tt SetServiceObjectSecurity} --- {\tt QueryServiceConfig2} --- {\tt ChangeServiceConfig2} --- {\tt QueryServiceStatusEx} --- {\tt EnumServicesStatusEx} {\tt ReadEventLog} --- {\tt GetEventDescription} --- {\tt BackupEventLog} --- {\tt ClearEventLog} --- {\tt ReportEvent} --- {\tt GetNumberOfEventLogRecords} --- {\tt GetOldestEventLogRecord} {\tt WTSEnumerateServers} --- {\tt WTSOpenServer} --- {\tt WTSCloseServer} --- {\tt WTSEnumerateSessions} --- {\tt WTSEnumerateProcesses} --- {\tt WTSTerminateProcess} --- {\tt WTSQuerySessionInformation} --- {\tt WTSQueryUserConfig} --- {\tt WTSSetUserConfig} --- {\tt WTSSendMessage} --- {\tt WTSDisconnectSession} --- {\tt WTSLogoffSession} --- {\tt WTSShutdownSystem} --- {\tt WTSWaitSystemEvent} {\tt SidToString} --- {\tt StringToSid} --- {\tt GuidToString} --- {\tt StringToGuid} =head2 Windows 2000 This version of Win32::Lanman now supports/implements specific calls which are only available in Windows 2000. If you call one of these routines from NT4, the call will fail and {\em GetLastError()\/} returns the code 127 (procedure not found). =head2 NOTE All of the functions return false if they fail. You can call {\em Win32::Lanman::GetLastError()\/} to get more error information. Throughout \$server is the name of the server you want the call to run against. If set to '', this signifies the local machine. In previous versions of this module, you were required to put two backslashes before the server name, as you would do at the cmd prompt, but from version 1.05 all server names will be automatically prefaced by two backslashes if they are missing. Note: Win32::Lanman defines some private error codes, which are not currently exported. You cannot call "net helpmsg" for a description of these. Instead you can find the meaning in the usererror.h file included as part of the distribution. =head2 DFS =over 4 Here we use the term to mean a root share, (Dfs path) associated with a Dfs link. Throughout this section if you specify a server and share the function applies to the server and share within the dfs tree. If you leave them empty, the function runs relative to the dfsroot. =item NetDfsAdd(\$entrypath, \$server, \$share, {\tt [}, \$comment{\tt [}, \$flags{\tt ]}{\tt ]}) Adds a new volume to the dfs root or adds another storage to a existing dfs volume. =item NetDfsEnum(\$server, $\backslash{}$@dfs) Enumerates all DFS-Entries on a DFS-Server. =item NetDfsGetInfo(\$entrypath, \$server, \$share, $\backslash{}$\%dfs) Gets information about a dfs volume. When you specify \$server and \$share you will get information of the volume and the specified storage. If \$server and \$share are empty, retrieves information for all storages in the volume. =item NetDfsRemove(\$entrypath, \$server, \$share) Removes a volume or storage space from the dfs directory; when applied to the latest storage in a volume, removes the volume from the dfs. =item NetDfsSetInfo(\$entrypath, \$server, \$share, $\backslash{}$\%dfs) Sets dfs volume information. Currently, you can only set the volume comment. =item NetDfsRename(\$oldEntrypath, \$newEntrypath) Renames a dfs volume. Not supported in NT4. =item NetDfsMove(\$oldEntrypath, \$newEntrypath) Moves a dfs volume. Not supported in NT4. =item NetDfsAddFtRoot(\$server, \$rootshare, \$ftdfs {\tt [}, \$comment{\tt ]}) Creates the root of a new domain-based Distributed File System implementation. If the root already exists, the function adds the specified server and share to the root. This function requires Windows 2000. =item NetDfsRemoveFtRoot(\$server, \$rootshare, \$ftdfs) Removes the specified server and share from a domain-based Distributed File System root. If the share is the last associated with the Dfs root, the function also deletes the root. This function requires Windows 2000. =item NetDfsRemoveFtRootForced(\$domain, \$server, \$rootshare, \$ftdfs) Removes the specified server and share from a domain-based Distributed File System root, even if the server is offline. If the share is the last associated with the Dfs root, the function also deletes the root. This function requires Windows 2000. =item NetDfsAddStdRoot(\$server, \$rootshare {\tt [}, \$comment{\tt ]}) Creates the root for a new stand-alone Distributed File System implementation. This function requires Windows 2000. =item NetDfsAddStdRootForced(\$server, \$rootshare, \$store {\tt [}, \$comment{\tt ]}) Creates the root for a new stand-alone Distributed File System implementation in a cluster technology environment, allowing an offline share to host the Dfs root. This function requires Windows 2000. =item NetDfsRemoveStdRoot(\$server, \$rootshare) Removes the server and share at the root of a stand-alone Distributed File System implementation. This function requires Windows 2000. =item {\em NetDfsManagerInitialize\/}(\$server) Reinitializes the Dfs service on the specified server. This function requires Windows 2000. =item NetDfsGetClientInfo(\$entrypath, \$server, \$share, $\backslash{}$\%info) Retrieves information about a Distributed File System link in the named Dfs root. This function requires Windows 2000. =item NetDfsSetClientInfo(\$entrypath, \$server, \$share, $\backslash{}$\%info) Associates information with a Distributed File System link in the named Dfs root. This function requires Windows 2000. =item NetDfsGetDcAddress(\$server, $\backslash{}$\%info) Retrieves information about a Distributed File System domain controller. This function requires Windows 2000. =back =head2 DFS EXAMPLES: =over 4 =item NetDfsAdd(\$entrypath, \$server, \$share, {\tt [}, \$comment{\tt [}, \$flags{\tt ]}{\tt ]}) create new dfs volume in the dfs root if(!Win32::Lanman::NetDfsAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", "testserver1", "testshare1", "comment", \&Win32::Lanman::DFS\underscore{}ADD\underscore{}VOLUME)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} add an additional storage space to an existing dfs volume if(!Win32::Lanman::NetDfsAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", "testserver2", "testshare2", "comment", \&Win32::Lanman::DFS\underscore{}RESTORE\underscore{}VOLUME)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsEnum(\$server, $\backslash{}$@dfs) Enumerates all directories in a dfs structure. @dfs contains all directories in the dfs root if(!Win32::Lanman::NetDfsEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@dfs)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$dfspath (@dfs) \{ print "\$\{\$dfspath\}\{'entrypath'\}$\backslash{}$t\$\{\$dfspath\}\{'comment'\}$\backslash{}$t\$\{\$dfspath\}\{'state'\}$\backslash{}$n"; {\em if\/}(exists(\$\{\$dfspath\}\{'storage'\})) \{ \$storage = \$\{\$dfspath\}\{'storage'\}; for(\$count = 0; \$count $<$= \$\#\$storage; \$count++) \{ print "$\backslash{}$t\$\{\$\$storage{\tt [}\$count{\tt ]}\}\{'servername'\}"; print "$\backslash{}$t\$\{\$\$storage{\tt [}\$count{\tt ]}\}\{'sharename'\}"; print "$\backslash{}$t\$\{\$\$storage{\tt [}\$count{\tt ]}\}\{'state'\}$\backslash{}$n"; \} \} \} =item NetDfsGetInfo(\$entrypath, \$server, \$share, $\backslash{}$\%dfs) gets information about volume $\backslash{}$$\backslash{}$testdfsserver$\backslash{}$dfsrootdir$\backslash{}$dfsdir and the storage testserver2$\backslash{}$testshare2 if(!Win32::Lanman::NetDfsGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", "testserver2", "testshare2", $\backslash{}$\%dfs)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$dfs\{'entrypath'\}$\backslash{}$t\$dfs\{'comment'\}$\backslash{}$t\$dfs\{'state'\}$\backslash{}$n"; {\em if\/}(exists(\$dfs\{'storage'\})) \{ \$store = \$dfs\{'storage'\}; for(\$count = 0; \$count $<$= \$\#\$store; \$count++) \{ print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'servername'\}"; print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'sharename'\}"; print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'state'\}$\backslash{}$n"; \} \} gets information about volume $\backslash{}$$\backslash{}$testdfsserver$\backslash{}$dfsrootdir$\backslash{}$dfsdir and all storages in $\backslash{}$$\backslash{}$testdfsserver$\backslash{}$dfsrootdir$\backslash{}$dfsdir if(!Win32::Lanman::NetDfsGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", '', '', $\backslash{}$\%dfs)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$dfs\{'entrypath'\}$\backslash{}$t\$dfs\{'comment'\}$\backslash{}$t\$dfs\{'state'\}$\backslash{}$n"; {\em if\/}(exists(\$dfs\{'storage'\})) \{ \$store = \$dfs\{'storage'\}; for(\$count = 0; \$count $<$= \$\#\$store; \$count++) \{ print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'server'\}"; print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'share'\}"; print "$\backslash{}$t\$\{\$\$store{\tt [}\$count{\tt ]}\}\{'state'\}$\backslash{}$n"; \} \} =item NetDfsRemove(\$entrypath, \$server, \$share) removes the storage testserver2$\backslash{}$testshare2 in volume $\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir. If there is only one storage, the volume will be removed too. if(!Win32::Lanman::NetDfsRemove("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", "testserver2", "testshare2")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsSetInfo(\$entrypath, \$server, \$share, $\backslash{}$\%dfs) Sets dfs volume comment to "this is a volume name". There is no difference, if you specify a storage or not. if(!Win32::Lanman::NetDfsSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver$\backslash{}$$\backslash{}$dfsrootdir$\backslash{}$$\backslash{}$dfsdir", '', '', \{'comment' =$>$ 'this is a volume name'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsAddFtRoot(\$server, \$rootshare, \$ftdfs {\tt [}, \$comment{\tt ]}) Creates the new dfs root testroot on the server $\backslash{}$$\backslash{}$testserver. It uses the share name testdfs and sets the comment test comment. if(!Win32::Lanman::NetDfsSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs", "testroot", "test comment")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsRemoveFtRoot(\$server, \$rootshare, \$ftdfs) Removes the dfs share testdfs from the dfs root testdfs on the server $\backslash{}$$\backslash{}$testserver. If testdfs is the last share in the dfs root, the function deletes the root testroot. if(!Win32::Lanman::NetDfsRemoveFtRoot("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs", "testroot")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsRemoveFtRootForced(\$domain, \$server, \$rootshare, \$ftdfs) Removes the dfs share testdfs from the dfs root testroot in the domain testdomain.com, even if the dfs server which hosts the share testdfs is offline. The function will be executed on the server $\backslash{}$$\backslash{}$testserver. If dfstest is the last share in the dfs root, the function deletes the root testroot. if(!Win32::Lanman::NetDfsRemoveFtRootForced("testdomain.com", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs", "testroot")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsAddStdRoot(\$server, \$rootshare {\tt [}, \$comment{\tt ]}) Creates the root testroot for a new stand-alone Distributed File System implementation on the server $\backslash{}$$\backslash{}$testserver and sets the comment to test comment. if(!Win32::Lanman::NetDfsAddStdRoot("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testroot", "test comment")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsAddStdRootForced(\$server, \$rootshare, \$store {\tt [}, \$comment{\tt ]}) Creates the root testroot for a new stand-alone Distributed File System implementation on the server $\backslash{}$$\backslash{}$testserver and sets the comment to test comment, even if the share does not exist. if(!Win32::Lanman::NetDfsAddStdRootForced("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testroot", "c:$\backslash{}$$\backslash{}$testdir", "test comment")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsRemoveStdRoot(\$server, \$rootshare) Removes the server/share $\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testdfs at the root of a stand-alone Distributed File System implementation. if(!Win32::Lanman::NetDfsRemoveStdRoot("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item {\em NetDfsManagerInitialize\/}(\$server) Reinitializes the Dfs service on the server $\backslash{}$$\backslash{}$testserver. {\em if\/}(!Win32::Lanman::NetDfsManagerInitialize("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsGetClientInfo(\$entrypath, \$server, \$share, $\backslash{}$\%info) Retrieves information about the $\backslash{}$$\backslash{}$testserver$\backslash{}$testroot dfs root. if(!Win32::Lanman::NetDfsGetClientInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testroot", "", "", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys info) \{ if(\$key eq "storage") \{ foreach \$count (0 .. \$\#\{\$info\{\$key\}\}) \{ print "storage{\tt [}\$count{\tt ]}:$\backslash{}$n"; foreach \$skey (sort keys \%\{\$\{\$info\{\$key\}\}{\tt [}\$count{\tt ]}\}) \{ print "$\backslash{}$t\$skey=\$\{\$\{\$info\{\$key\}\}{\tt [}\$count{\tt ]}\}\{\$skey\}$\backslash{}$n"; \} \} \} else \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} \} Retrieves information about the testdfs link in the $\backslash{}$$\backslash{}$testserver$\backslash{}$testroot dfs root. if(!Win32::Lanman::NetDfsGetClientInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testroot", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsSetClientInfo(\$entrypath, \$server, \$share, $\backslash{}$\%info) Set the timeout to 200 seconds for the testdfs link in the $\backslash{}$$\backslash{}$testserver$\backslash{}$testroot dfs root. if(!Win32::Lanman::NetDfsSetClientInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testroot", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdfs", \{ tomeout =$>$ 200 \})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetDfsGetDcAddress(\$server, $\backslash{}$\%info) Retrieves information about a Distributed File System domain controller $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetDfsGetDcAddress("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =back =head2 Directory Services The following functions are related to The Active Directory. =over 4 =item NetGetJoinableOUs(\$server, \$domain, \$account, \$password, $\backslash{}$@ous) Retrieves a list of organizational units in which a computer account can be created. This function requires Windows 2000. =item NetGetJoinInformation(\$server, $\backslash{}$\%info) Retrieves the join status information for the specified server. This function requires Windows 2000. =item NetJoinDomain(\$server, \$domain, \$account\underscore{}ou, \$account, \$password, \$options) Joins a computer to a workgroup or domain. This function requires Windows 2000. =item NetRenameMachineInDomain(\$server, \$new\underscore{}machine\underscore{}name, \$account, \$password, \$options) Changes the name of a computer in a domain. This function requires Windows 2000. =item NetUnjoinDomain(\$server, \$account, \$password, \$options) Unjoins a computer from a workgroup or a domain. This function requires Windows 2000. =item NetValidateName(\$server, \$name, \$account, \$password, \$name\underscore{}type) Verifies the validity of a computer, workgroup or domain name. This function requires Windows 2000. =item {\em NetRegisterDomainNameChangeNotification\/}(\$notification\underscore{}handle) Enables an application to receive a notification when the name of the current domain changes. When the domain name changes, the specified event object is set to the signaled state. This function requires Windows 2000. =item {\em NetUnregisterDomainNameChangeNotification\/}(\$notification\underscore{}handle) Ends a domain name change notification started by the NetRegisterDomainNameChangeNotification function. This function requires Windows 2000. =back =head2 Directory Services EXAMPLES: =over 4 =item NetGetJoinableOUs(\$server, \$domain, \$account, \$password, $\backslash{}$@ous) Retrieves a list of organizational units in the domain testdomain.com in which a computer account can be created. The command is executed on the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetGetJoinableOUs("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain.com", "testaccount", "testpassword", $\backslash{}$@ous)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em ou\/}(@ous) \{ print "\$ou$\backslash{}$n"; \} =item NetGetJoinInformation(\$server, $\backslash{}$\%info) Retrieves the join status information for the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetGetJoinInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetJoinDomain(\$server, \$domain, \$account\underscore{}ou, \$account, \$password, \$options) Joins the computer $\backslash{}$$\backslash{}$testserver to the domain testdomain.com. The computer will be rejoined if it is already joined. if(!Win32::Lanman::NetJoinDomain("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain.com", "testou", "testaccount", "testpassword", \&NETSETUP\underscore{}JOIN\underscore{}DOMAIN $|$ \&NETSETUP\underscore{}DOMAIN\underscore{}JOIN\underscore{}IF\underscore{}JOINED)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetRenameMachineInDomain(\$server, \$new\underscore{}machine\underscore{}name, \$account, \$password, \$options) Changes the name of a the computer testserver to testcomputer in the domain. if(!Win32::Lanman::NetRenameMachineInDomain("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testcomputer", "testaccount", "testpassword", \&NETSETUP\underscore{}ACCT\underscore{}CREATE)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUnjoinDomain(\$server, \$account, \$password, \$options) Unjoins the computer $\backslash{}$$\backslash{}$testserver from the domain. if(!Win32::Lanman::NetUnjoinDomain("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testaccount", "testpassword")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetValidateName(\$server, \$name, \$account, \$password, \$name\underscore{}type) Verifies the validity of domain name testdomain. if(!Win32::Lanman::NetValidateName("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", "testaccount", "testpassword", \&NetSetupDomain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item {\em NetRegisterDomainNameChangeNotification\/}(\$notification\underscore{}handle) Enables an application to receive a notification when the name of the current domain changes. \# you must have a valid handle \# \$handle = {\em if\/}(!Win32::Lanman::NetRegisterDomainNameChangeNotification(\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \# wait til the handle is signaled \# {\em WaitForSingleObject\/}(\$handle) =item {\em NetUnregisterDomainNameChangeNotification\/}(\$notification\underscore{}handle) Ends a domain name change notification started by the NetRegisterDomainNameChangeNotification function. \# you must have a valid handle \# \$handle = {\em if\/}(!Win32::Lanman::NetUnregisterDomainNameChangeNotification(\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 File =over 4 =item NetFileEnum(\$server, \$basepath, \$user, $\backslash{}$@info) Supplies information about some or all open files on a server. =item NetFileGetInfo(\$server, \$fileid, $\backslash{}$\%info) Retrieves information about a particular open file (specified by \$fileid) resource on \$server. =item NetFileClose(\$server, \$fileid) Closes a file on a server. =back =head2 File EXAMPLES: =over 4 =item NetFileEnum(\$server, \$basepath, \$user, $\backslash{}$@info) Enumerates info about some or all open files on \$server. The following sample enumerates all information about all open files on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetFileEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', '', $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$info (@infos) \{ @keys = {\em keys\/}(\%\$info); foreach \${\em key\/}(@keys) \{ print "\$key: \$\{\$info\}\{\$key\}$\backslash{}$n"; \} print "$\backslash{}$n"; \} The following code supplies information about all open files below c:$\backslash{}$winnt opened by user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetFileEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "c:$\backslash{}$$\backslash{}$winnt", "testuser", $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$info (@infos) \{ @keys = {\em keys\/}(\%\$info); foreach \${\em key\/}(@keys) \{ print "\$key: \$\{\$info\}\{\$key\}$\backslash{}$n"; \} print "$\backslash{}$n"; \} =item NetFileGetInfo(\$server, \$fileid, $\backslash{}$\%info) Retrieves information about a particular file being opened on \$server, fileid must be valid and obtained by NetFileEnum. \$fileid = 125; if(!Win32::Lanman::NetFileGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$fileid, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = {\em keys\/}(\%info); foreach \${\em key\/}(@keys) \{ print "\$key: \$info\{\$key\}$\backslash{}$n"; \} =item NetFileClose(\$server, \$fileid) As with NetFileGetInfo, fileid must be valid and obtained by NetFileEnum. The following code closes the file with fileid 125 on server $\backslash{}$$\backslash{}$testserver. \$fileid = 125; if(!Win32::Lanman::NetFileClose("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$fileid)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Get =over 4 =item MultinetGetConnectionPerformance($\backslash{}$\%netresource, $\backslash{}$\%info) Returns information about the expected performance of a connection used to access a network resource. =item NetGetAnyDCName(\$server, \$domain, $\backslash{}$\$dcname) Returns the name of a domain controller in a specified domain. Does NOT work with Trusted Domains. You get the error code 1355 (domain doesn't exist). In this case proceed as follows: get your pdc or a bdc and execute the NetGetAnyDCName call there. \# your primary domain name \$my\underscore{}domain = "my\underscore{}domain"; \# a trusted domain name \$trust\underscore{}domain = "trust\underscore{}domain"; \# get the pdc on your local machine for \$my\underscore{}domain NetGetDCName('', \$my\underscore{}domain, $\backslash{}$\$pdc); \# now get a dc in the trusted domain NetGetAnyDCName(\$pdc, \$trusted\underscore{}domain, $\backslash{}$\$dc); =item NetGetDCName(\$server, \$domain, $\backslash{}$\$pdcname) Returns the name of the primary domain controller for domain \$domain. =item NetGetDisplayInformationIndex(\$server, \$level, \$prefix, $\backslash{}$\$index) Gets the index of the first display information entry whose name begins with a specified string or alphabetically follows the string. =item NetQueryDisplayInformation(\$server, \$level, \$index, \$entries, $\backslash{}$@info) Returns user, computer, or global group account information. The number of entries to retrieve (\$entries) must be supplied and must be a decimal digit =back =head2 Get EXAMPLES: =over 4 =item MultinetGetConnectionPerformance($\backslash{}$\%netresource, $\backslash{}$\%info) Returns information about the expected performance of a connection specified in \%netresource used to access a network resource. You have to specify a remote name (server and share) or a local name (redirected device name) if(!Win32::Lanman::MultinetGetConnectionPerformance(\{'remotename' =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$ipc$\backslash{}$\$"\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = {\em keys\/}(\%info); foreach \${\em key\/}(@keys) \{ print "\$key: \$info\{\$key\}$\backslash{}$n"; \} if(!Win32::Lanman::MultinetGetConnectionPerformance(\{'localname' =$>$ "f:"\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = {\em keys\/}(\%info); foreach \${\em key\/}(@keys) \{ print "\$key: \$info\{\$key\}$\backslash{}$n"; \} =item NetGetAnyDCName(\$server, \$domain, $\backslash{}$\$dcname) Returns the name of a domain controller in domain testdomain. The command will be executed on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetGetAnyDCName("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", $\backslash{}$\$dcname)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$dcname; =item NetGetDCName(\$server, \$domain, $\backslash{}$\$pdcname) Returns the name of the primary domain controller in domain testdomain. The command will be executed on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetGetDCName("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", $\backslash{}$\$pdcname)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$pdcname; =item NetGetDisplayInformationIndex(\$server, \$level, \$prefix, $\backslash{}$\$index) Gets the index of the first display information entry whose name begins with test or alphabetically follows test. The command will be executed on server $\backslash{}$$\backslash{}$testserver. You can get an index for users accounts (pass 1), machine accounts (pass 2) or group accounts (pass 3). if(!Win32::Lanman::NetGetDisplayInformationIndex("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 1, "test", $\backslash{}$\$index)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$index; =item NetQueryDisplayInformation(\$server, \$level, \$index, \$entries, $\backslash{}$@info) Returns user, computer, or global group account information. The command will be excuted on server $\backslash{}$$\backslash{}$testserver. A maximum of 10 accounts will be returned for each call. It starts at index 12 (every account has an index starting at 0). You can get a starting index by call NetGetDisplayInformationIndex. At first we get user accounts. \$index = 12; while(Win32::Lanman::NetQueryDisplayInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 1, \$index, 10, $\backslash{}$@users)) \{ foreach \$user (@users) \{ print "\$\{\$user\}\{'name'\}$\backslash{}$t"; print "\$\{\$user\}\{'comment'\}$\backslash{}$t"; print "\$\{\$user\}\{'full\underscore{}name'\}$\backslash{}$t"; print "\$\{\$user\}\{'flags'\}$\backslash{}$t"; print "\$\{\$user\}\{'user\underscore{}id'\}$\backslash{}$t"; print "\$\{\$user\}\{'next\underscore{}index'\}$\backslash{}$n"; \} last if \$\#users == $-$1; \$index = \$\{\$users{\tt [}\$\#users{\tt ]}\}\{'next\underscore{}index'\}; \} Dito for machine accounts. Start at machines names beginning with test. We get 20 accounts on each call. if(!Win32::Lanman::NetGetDisplayInformationIndex("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 2, "test", $\backslash{}$\$index)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} while(Win32::Lanman::NetQueryDisplayInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 2, \$index, 20, $\backslash{}$@machines)) \{ foreach \$machine (@machines) \{ print "\$\{\$machine\}\{'name'\}$\backslash{}$t"; print "\$\{\$machine\}\{'comment'\}$\backslash{}$t"; print "\$\{\$machine\}\{'flags'\}$\backslash{}$t"; print "\$\{\$machine\}\{'user\underscore{}id'\}$\backslash{}$t"; print "\$\{\$machine\}\{'next\underscore{}index'\}$\backslash{}$n"; \} last if \$\#machines == $-$1; \$index = \$\{\$machines{\tt [}\$\#machines{\tt ]}\}\{'next\underscore{}index'\}; \} Dito for group accounts. Start at begin (index position 0). We get 5 accounts on each call. \$index = 0; while(Win32::Lanman::NetQueryDisplayInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 3, \$index, 5, $\backslash{}$@groups)) \{ foreach \$group (@groups) \{ print "\$\{\$group\}\{'name'\}$\backslash{}$t"; print "\$\{\$group\}\{'comment'\}$\backslash{}$t"; print "\$\{\$group\}\{'group\underscore{}id'\}$\backslash{}$t"; print "\$\{\$group\}\{'attributes'\}$\backslash{}$t"; print "\$\{\$group\}\{'next\underscore{}index'\}$\backslash{}$n"; \} last if \$\#groups == $-$1; \$index = \$\{\$groups{\tt [}\$\#groups{\tt ]}\}\{'next\underscore{}index'\}; \} =back =head2 Groups =over 4 =item NetGroupAdd(\$server, \$group{\tt [}, \$comment{\tt ]}) Creates a new global group \$group on \$server. An optional \$comment may be specified. =item NetGroupAddUser(\$server, \$group, \$user) Adds a user to a global group \$group on \$server. =item NetGroupDel(\$server, \$group) Deletes the global group \$group on \$server. =item NetGroupDelUser(\$server, \$group, \$user) Deletes a user from a global group \$group on server \$server. =item NetGroupEnum(\$server, $\backslash{}$@groups) Enumerates all global groups defined on server \$server. If successfull, each array element contains a hash with group name ('name'), comment ('comment'), group id ('group\underscore{}id') and attributes ('attributes'). =item NetGroupGetInfo(\$server, \$group, $\backslash{}$\%info) Gets the name, comment, group id and attributes of a global group, storing the result in \%info (\$group should be equal to \$info\{'name'\}). =item NetGroupGetUsers(\$server, \$group, $\backslash{}$@users) Gets the users in a global group. =item NetGroupSetInfo(\$server, \$group, $\backslash{}$\%info) Sets the name and the comment of a global group. Note if \$group is set and not equal to \$info\{'name'\}, the group will be renamed. If \$info\{name\} is not set, only the comment will be set. =item NetGroupSetUsers(\$server, \$group, $\backslash{}$@users) Sets the members of a global group. Note: This operation is destructive; previous users will be removed. =back =head2 Group EXAMPLES: =over 4 =item NetGroupAdd(\$server, \$group{\tt [}, \$comment{\tt ]}) Creates a new global group testgroup on server $\backslash{}$$\backslash{}$testserver. $\backslash{}$$\backslash{}$testserver must be a domain controller. if(!Win32::Lanman::NetGroupAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", "test group comment")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetGroupAddUser(\$server, \$group, \$user) Adds a user testuser to the global group testgroup on $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetGroupAddUser("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", "testuser")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetGroupDel(\$server, \$group) Deletes the global group testgroup on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetLocalGroupDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetGroupDelUser(\$server, \$group, \$user) Removes a user testuser from global group testgroup on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetLocalGroupDelMembers("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", "testuser")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetGroupEnum(\$server, $\backslash{}$@groups) Retrieves all global groups on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetGroupEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@groups)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$group (@groups) \{ print "\$\{\$group\}\{'name'\}$\backslash{}$t\$\{\$group\}\{'comment'\}$\backslash{}$t\$\{\$group\}\{'group\underscore{}id'\}$\backslash{}$t\$\{\$group\}\{'attributes'\}$\backslash{}$n"; \} =item NetGroupGetInfo(\$server, \$group, $\backslash{}$\%info) Retrieves information about the global group testgroup on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetGroupGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$info\{'name'\}$\backslash{}$t\$info\{'comment'\}$\backslash{}$t\$info\{'group\underscore{}id'\}$\backslash{}$t\$info\{'attributes'\}$\backslash{}$n"; =item NetGroupGetUsers(\$server, \$group, $\backslash{}$@users) Retrieves all user in global group testgroup on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetGroupGetUsers("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", $\backslash{}$@users)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$user (@users) \{ \#don't print these binary data \#print "\$\{\$user\}\{'sid'\}$\backslash{}$n"; print "\$\{\$user\}\{'name'\}$\backslash{}$t\$\{\$user\}\{'attributes'\}$\backslash{}$n"; \} =item NetGroupSetInfo(\$server, \$group, $\backslash{}$\%info) Sets information for the global group testgroup on server $\backslash{}$$\backslash{}$testserver. Only the group name and the comment can be set. Specifying a new name renames the group. if(!Win32::Lanman::NetGroupSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", \{'name' =$>$ 'newtestgrp', 'comment' =$>$ 'comment for testgroup'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetGroupSetUsers(\$server, \$group, $\backslash{}$@users) Sets user user1, user2 and user3 as members of the global group testgroup on server $\backslash{}$$\backslash{}$testserver. All previous group members will be removed. if(!Win32::Lanman::NetGroupSetUsers("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", {\tt [}'user1', 'user2', 'user3'{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Local Groups =over 4 =item NetLocalGroupAdd(\$server, \$group{\tt [}, \$comment{\tt ]}) Creates a new local group \$group on server \$server. You can specify an optional comment \$comment. =item NetLocalGroupAddMember(\$server, \$group, \$sid) Adds users \$sid to a local group on server \$server. =item NetLocalGroupAddMembers(\$server, \$group, $\backslash{}$@members) Adds members (global groups or users) to a local group \$group on \$server. You can specficy the users or global groups with or without domain name. =item NetLocalGroupAddMembersBySid(\$server, \$group, $\backslash{}$@members) Adds members (global groups or users) to a local group \$group on \$server. You must specficy the users or global groups by sid's. =item NetLocalGroupDel(\$server, \$group) Deletes the local group \$group on server \$server. =item NetLocalGroupDelMember(\$server, \$group, \$sid) Removes users \$sid from a local group \$group on server \$server. =item NetLocalGroupDelMembers(\$server, \$group, $\backslash{}$@members) Deletes members (global groups or users) of a local group \$group on server \$server. You can specficy the users or global groups with or without domain name. =item NetLocalGroupDelMembersBySid(\$server, \$group, $\backslash{}$@members) Deletes members (global groups or users) of a local group \$group on server \$server. You must specficy the users or global groups by sid's. =item NetLocalGroupEnum(\$server, $\backslash{}$@groups) Enumerates all local groups defined on server \$server. If successfull, each array element contains a hash with group name ('name') and comment ('comment'). =item NetLocalGroupGetInfo(\$server, \$group, $\backslash{}$\%info) Gets the name and the comment of a local group (\$group should be returned equal to \$info\{'name'\}). =item NetLocalGroupGetMembers(\$server, \$group, $\backslash{}$@members) Gets the members of a local group (users and global groups). =item NetLocalGroupSetInfo(\$server, \$group, $\backslash{}$\%info) Sets the name and the comment of a local group ( if \$group is not equal to \$info\{'name'\}, the group will be renamed). =item NetLocalGroupSetMembers(\$server, \$group, $\backslash{}$@members) Sets the members of a local group (previous members will be removed). Members can be users and/or global groups. =item NetLocalGroupSetMembersBySid(\$server, \$group, $\backslash{}$@members) Sets the members of a local group (previous members will be removed). You must specficy the users or global groups by sid's. =back =head2 Local Group EXAMPLES: =over 4 =item NetLocalGroupAdd(\$server, \$group{\tt [}, \$comment{\tt ]}) Creates a new local group testgroup on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetLocalGroupAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", "test group comment")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupAddMember(\$server, \$group, \$sid) Adds testuser's \$sid to the local group testgroup on server $\backslash{}$$\backslash{}$testserver. You must retrieve the user sid with Win32::LookupAccountName. \$sid = ... if(!Win32::Lanman::NetLocalGroupAddMember("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", \$sid)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupAddMembers(\$server, \$group, $\backslash{}$@members) Adds global groups (glb\underscore{}grp, domain$\backslash{}$glb\underscore{}grp) and/or users (user, domain$\backslash{}$user) to the local group testgroup on $\backslash{}$$\backslash{}$testserver. unless(Win32::Lanman::NetLocalGroupAddMembers("testserver", "testgroup", {\tt [}'glb\underscore{}grp', 'domain$\backslash{}$glb\underscore{}grp', 'user', 'domain$\backslash{}$user'{\tt ]}) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupAddMembersBySid(\$server, \$group, $\backslash{}$@members) Adds global groups (glb\underscore{}grp, domain$\backslash{}$glb\underscore{}grp) and/or users (user, domain$\backslash{}$user) to the local group testgroup on $\backslash{}$$\backslash{}$testserver. unless(Win32::Lanman::LsaLookupNames("testserver", {\tt [}'glb\underscore{}grp', 'domain$\backslash{}$glb\underscore{}grp', 'user', 'domain$\backslash{}$user'{\tt ]}, $\backslash{}$@sids)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @members = map \{ \$\{\$\underscore{}\}\{sid\} \} @sids; unless(Win32::Lanman::NetLocalGroupAddMembersBySid("testserver", "testgroup", $\backslash{}$@members)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupDel(\$server, \$group) Deletes the local group testgroup on server $\backslash{}$$\backslash{}$testserver. unless(Win32::Lanman::NetLocalGroupDel("testserver", "testgroup")) \{ print 'Sorry, something went wrong; in ( Win32::Lanman::NetLocalGroupDel ) error: '; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupDelMember(\$server, \$group, \$sid) Removes testuser's \$sid from the local group testgroup on server $\backslash{}$$\backslash{}$testserver. You must retrieve the user sid with Win32::LookupAccountName. \$sid = ... if(!Win32::Lanman::NetLocalGroupDelMember("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", \$sid)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupDelMembers(\$server, \$group, $\backslash{}$@members) Removes groups (glb\underscore{}grp, domain$\backslash{}$glb\underscore{}grp) and/or users (user, domain$\backslash{}$user) from the members of the local group testgroup on $\backslash{}$$\backslash{}$testserver. unless(Win32::Lanman::NetLocalGroupDelMembers("testserver", "testgroup", {\tt [}'glb\underscore{}grp', 'domain$\backslash{}$glb\underscore{}grp', 'user', 'domain$\backslash{}$user'{\tt ]}) ) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupDelMembersBySid(\$server, \$group, $\backslash{}$@members) Removes groups (glb\underscore{}grp, domain$\backslash{}$glb\underscore{}grp) and/or users (user, domain$\backslash{}$user) from the members of the local group testgroup on $\backslash{}$$\backslash{}$testserver. unless(Win32::Lanman::LsaLookupNames("testserver", {\tt [}'glb\underscore{}grp', 'domain$\backslash{}$glb\underscore{}grp', 'user', 'domain$\backslash{}$user'{\tt ]}, $\backslash{}$@sids)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @members = map \{ \$\{\$\underscore{}\}\{sid\} \} @sids; unless(Win32::Lanman::NetLocalGroupDelMembersBySid("testserver", "testgroup", $\backslash{}$@members)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupEnum(\$server, $\backslash{}$@groups) Retrieves all local groups on server $\backslash{}$$\backslash{}$testserver unless(Win32::Lanman::NetLocalGroupEnum("testserver", $\backslash{}$@groups)) \{ print 'Sorry, something went wrong in (Win32::Lanman::NetLocalGroupEnum) ; error: '; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$group (@groups) \{ print "\$\{\$group\}\{'name'\}$\backslash{}$t\$\{\$group\}\{'comment'\}$\backslash{}$n"; \} =item NetLocalGroupGetInfo(\$server, \$group, $\backslash{}$\%info) Retrieves information about the local group testgroup on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetLocalGroupGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$info\{'name'\}$\backslash{}$t\$info\{'comment'\}$\backslash{}$n"; =item NetLocalGroupGetMembers(\$server, \$group, $\backslash{}$@members) Retrieves all global groups and /or user in local group testgroup on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetLocalGroupGetMembers("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testgroup", $\backslash{}$@members)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$member (@members) \{ \#don't print these binary data \#print "\$\{\$member\}\{'sid'\}$\backslash{}$n"; print "\$\{\$member\}\{'domainandname'\}$\backslash{}$t\$\{\$member\}\{'sidusage'\}$\backslash{}$n"; \} =item NetLocalGroupSetInfo(\$server, \$group, $\backslash{}$\%info) Sets information for the local group testgroup on server $\backslash{}$$\backslash{}$testserver. Only the group name and the comment can be set. Since we specify a new name the group is renamed. unless(Win32::Lanman::NetLocalGroupSetInfo("testserver", "testgroup", \{'name' =$>$ 'newtestgrp', 'comment' =$>$ 'comment for testgroup'\} ) ) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupSetMembers(\$server, \$group, $\backslash{}$@members) Sets users (user1 and testdomain$\backslash{}$user1) and global groups (testdomain$\backslash{}$group1) as members of the local group testgroup on server $\backslash{}$$\backslash{}$testserver. All previous group members will be removed. unless(Win32::Lanman::NetLocalGroupSetMembers("testserver", "testgroup", {\tt [}'user1', 'testdomain$\backslash{}$group1', 'testdomain$\backslash{}$user1'{\tt ]} ) ) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetLocalGroupSetMembersBySid(\$server, \$group, $\backslash{}$@members) Sets users (user1 and testdomain$\backslash{}$user1) and global groups (testdomain$\backslash{}$group1) as members of the local group testgroup on server $\backslash{}$$\backslash{}$testserver. All previous group members will be removed. unless(Win32::Lanman::LsaLookupNames("testserver", {\tt [}'user1', 'testdomain$\backslash{}$user1', 'testdomain$\backslash{}$group1'{\tt ]}, $\backslash{}$@sids)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @members = map \{ \$\{\$\underscore{}\}\{sid\} \} @sids; unless(Win32::Lanman::NetLocalGroupSetMembersBySid("testserver", "testgroup", $\backslash{}$@members)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Netlogon =over 4 =item I\underscore{}NetLogonControl(\$server, \$function, $\backslash{}$\%info) Queries, synchonizes or replicates the sam database between PDC and \$server. Avoid direct calls. Use the wrapper functions below. =item I\underscore{}NetLogonControl2(\$server, \$function, \$data, $\backslash{}$\%info) Queries, synchonizes or replicates the sam database between PDC and \$server. Queries and resets secure channels. Notifies a new transport is coming up. Finds user names. Avoid direct calls. Use the wrapper functions below. =item LogonControlQuery(\$server, $\backslash{}$\%info) Queries the status of the sam database on \$server. =item LogonControlReplicate(\$server, $\backslash{}$\%info) Replicates the changes of the sam database on \$server. =item LogonControlSynchronize(\$server, $\backslash{}$\%info) Synchronizes the sam database between \$server and a PDC. =item LogonControlPdcReplicate(\$server, $\backslash{}$\%info) Forces all BDC's to synchronize the sam database with the PDC \$server. =item LogonControlRediscover(\$server, \$domain, $\backslash{}$\%info) Resets the secure channel for a domain \$domain on a server \$server. =item LogonControlTCQuery(\$server, \$domain, $\backslash{}$\%info) Queries the status of the secure channel for domain \$domain on a server \$server. =item LogonControlTransportNotify(\$server, $\backslash{}$\%info) Informs the server \$server about the coming up of a new transport. =item LogonControlFindUser(\$server, \$user, $\backslash{}$\%info) Finds a user \$user in a trusted domain. The command will be executed on server \$server. =item NetEnumerateTrustedDomains(\$server, $\backslash{}$@domains) Enumerates all trusted domain names. The command will be executed on server \$server. =item I\underscore{}NetGetDCList(\$server, \$domain, $\backslash{}$@controllers) Enumerates all domain controllers in a domain. The command will be executed on server \$server. =back =head2 Netlogon EXAMPLES: =over 4 =item I\underscore{}NetLogonControl(\$server, \$function, $\backslash{}$\%info) Queries the status of $\backslash{}$$\backslash{}$testserver. $\backslash{}$$\backslash{}$testserver must be a PDC or BDC. if(!Win32::Lanman::I\underscore{}NetLogonControl("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}QUERY, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Replicates the sam changes of $\backslash{}$$\backslash{}$testserver with the PDC. $\backslash{}$$\backslash{}$testserver must be a BDC. if(!Win32::Lanman::I\underscore{}NetLogonControl("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}REPLICATE, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Synchronizes the sam of $\backslash{}$$\backslash{}$testserver with the PDC. $\backslash{}$$\backslash{}$testserver must be a PDC or BDC. if(!Win32::Lanman::I\underscore{}NetLogonControl("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}SYNCHRONIZE, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Forces to send a synchronize request to all BDC's. $\backslash{}$$\backslash{}$testserver must be a PDC. if(!Win32::Lanman::I\underscore{}NetLogonControl("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}PDC\underscore{}REPLICATE, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item I\underscore{}NetLogonControl2(\$server, \$function, $\backslash{}$\%info) Rediscovers a secure channel for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::I\underscore{}NetLogonControl2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}REDISCOVER, "testdomain", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Queries the status of the secure channel for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::I\underscore{}NetLogonControl2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}TC\underscore{}QUERY, "testdomain", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Informs the server $\backslash{}$$\backslash{}$testserver about a new transport coming up. if(!Win32::Lanman::I\underscore{}NetLogonControl2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}TRANSPORT\underscore{}NOTIFY, '', $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Retrieves which trusted domain will log on user testuser. The command will be excuted on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::I\underscore{}NetLogonControl2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&NETLOGON\underscore{}CONTROL\underscore{}FIND\underscore{}USER, "testuser", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlQuery(\$server, $\backslash{}$\%info) Queries the status of $\backslash{}$$\backslash{}$testserver. $\backslash{}$$\backslash{}$testserver must be a PDC or BDC. if(!Win32::Lanman::LogonControlQuery("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlReplicate(\$server, $\backslash{}$\%info) Replicates the sam changes of $\backslash{}$$\backslash{}$testserver with the PDC. $\backslash{}$$\backslash{}$testserver must be a BDC. if(!Win32::Lanman::LogonControlReplicate("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlSynchronize(\$server, $\backslash{}$\%info) Synchronizes the sam of $\backslash{}$$\backslash{}$testserver with the PDC. $\backslash{}$$\backslash{}$testserver must be a PDC or BDC. if(!Win32::Lanman::LogonControlSynchronize("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlPdcReplicate(\$server, $\backslash{}$\%info) Forces a synchronize request to be sent to all BDC's. $\backslash{}$$\backslash{}$testserver must be a PDC. if(!Win32::Lanman::LogonControlPdcReplicate("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlRediscover(\$server, \$domain, $\backslash{}$\%info) Rediscovers a secure channel for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LogonControlRediscover("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlTCQuery(\$server, \$domain, $\backslash{}$\%info) Queries the status of the secure channel for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LogonControlTCQuery("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlTransportNotify(\$server, $\backslash{}$\%info) Informs the server $\backslash{}$$\backslash{}$testserver about the coming up of a new transport. if(!Win32::Lanman::LogonControlTransportNotify("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LogonControlFindUser(\$server, \$user, $\backslash{}$\%info) Retrieves which trusted domain will log on user testuser. The command will be excuted on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LogonControlFindUser("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetEnumerateTrustedDomains(\$server, $\backslash{}$@domains) Enumerates all trusted domain names. The command will be executed on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetEnumerateTrustedDomains("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@domains)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$domain (@domains) \{ print "\$domain$\backslash{}$n"; \} =item I\underscore{}NetGetDCList(\$server, \$domain, $\backslash{}$@controllers) Enumerates all domain controllers in the domain testdomain. The command will be executed on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::I\underscore{}NetGetDCList("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", $\backslash{}$@servers)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$server (@servers) \{ print "\$server$\backslash{}$n"; \} =back =head2 Message Related Functions =over 4 =item NetMessageBufferSend(\$server, \$to, \$from, \$message) Sends a message. =item NetMessageNameAdd(\$server, \$messagename) Registers a message alias in the message name table. =item NetMessageNameAdd(\$server, \$messagename) Deletes a message alias from the table of message aliases. =item NetMessageNameEnum(\$server, $\backslash{}$@info) Lists the message aliases that will receive messages. =item NetMessageNameGetInfo(\$server, \$messagename, $\backslash{}$\$info) Retrieves information about a message alias in the message name table. =back =head2 Message Related Functions EXAMPLES: =over 4 =item NetMessageBufferSend(\$server, \$to, \$from, \$message) Sends the message "this is a message" from computer1 to user1. The command will be executed on $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetMessageBufferSend("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "user1", "computer1", "this is a message")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetMessageNameAdd(\$server, \$messagename) Registers the message alias user1 in the message on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetMessageNameAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser1")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetMessageNameDel(\$server, \$messagename) Deletes the message alias user1 in the message on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetMessageNameDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser1")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetMessageNameEnum(\$server, \$messagename) Lists the message aliases that will receive messages on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetMessageNameEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach (@info) \{ print "\$\underscore{}$\backslash{}$n"; \} =item NetMessageNameGetInfo(\$server, \$messagename, $\backslash{}$\$info) Retrieves information about the message alias user1 in the message name table on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetMessageNameEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "user1", $\backslash{}$\$info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$info; =back =head2 Policy and Privileges (LSA) =over 4 =item LsaQueryInformationPolicy(\$server, \$infotype, $\backslash{}$\%info) Queries policy information. Don't call LsaQueryInformationPolicy directly. Use the LsaQueryXXXPolicy wrappers instead. The following are equivalent, Win32::Lanman::LsaQueryInformationPolicy("", \&PolicyAuditFullQueryInformation, $\backslash{}$\%info); and Win32::Lanman::LsaQueryAuditFullPolicy("", $\backslash{}$\%info); Please use the second form , it is less prone to error. =item LsaSetInformationPolicy(\$server, \$infotype, $\backslash{}$\%info) Sets policy information. Don't call LsaSetInformationPolicy directly. Use the LsaSetXXXPolicy wrappers instead (see below). =item LsaQueryAuditLogPolicy(\$server, $\backslash{}$\%info) Queries audit log policy information. =item LsaQueryAuditEventsPolicy(\$server, $\backslash{}$\%info) Queries audit event policy information (if auditing is enabled and which events will be logged). =item LsaSetAuditEventsPolicy(\$server, $\backslash{}$\%info) Sets audit event policy information. =item LsaQueryPrimaryDomainPolicy(\$server, $\backslash{}$\%info) Queries primary domain policy information (domain name and domain sid). =item LsaSetPrimaryDomainPolicy(\$server, $\backslash{}$\%info) Sets primary domain policy information (domain name and domain sid). =item LsaQueryPdAccountPolicy(\$server, $\backslash{}$\%info) Queries the primary domain account used for authentication and lookup requests. It returns always an empty string. This should be a bug in the call. =item LsaQueryAccountDomainPolicy(\$server, $\backslash{}$\%info) Queries account domain policy information (workstation name and sid). =item LsaSetAccountDomainPolicy(\$server, $\backslash{}$\%info) Sets account domain policy information (workstation name and sid). =item LsaQueryServerRolePolicy(\$server, $\backslash{}$\%info) Queries server role policy information (type of server: pdc, bdc). =item LsaSetServerRolePolicy(\$server, $\backslash{}$\%info) Sets server role policy information (type of server: pdc, bdc). =item LsaQueryReplicaSourcePolicy(\$server, $\backslash{}$\%info) Queries the replication source server (pdc) policy information. =item LsaSetReplicaSourcePolicy(\$server, $\backslash{}$\%info) Sets the replication source server (pdc) policy information. =item LsaQueryDefaultQuotaPolicy(\$server, $\backslash{}$\%info) Queries the default quota policy information. =item LsaSetDefaultQuotaPolicy(\$server, $\backslash{}$\%info) Sets the default quota policy information. =item LsaQueryAuditFullPolicy(\$server, $\backslash{}$\%info) Queries the audit full policy information (if a shutdown is raised, when the audit log is full and if the log is full). =item LsaQueryAuditFullPolicy(\$server, $\backslash{}$\%info) Sets the audit full policy information (if a shutdown is raised, when the audit log is full). =item LsaQueryDnsDomainPolicy(\$server, $\backslash{}$\%info) Queries the dns domain policy information. This call is only supported in nt 5 and it's not tested! =item LsaSetDnsDomainPolicy(\$server, $\backslash{}$\%info) Sets the dns domain policy information. This call is only supported in nt 5 and it's not tested! =item LsaEnumerateTrustedDomains(\$server, $\backslash{}$@domains) Enumerates all trusted domains. If you execute this on a workstation or a member server, you'll get your domain and the domain sid. If you execute this on a PDC or BDC, you'll get a list of all trusted domains and their sid's. =item LsaLookupNames(\$server, $\backslash{}$@accounts, $\backslash{}$@info) Looks up for account names and returns the appropriate rid, domains, sid's and domain sid's. Unlike to the LsaLookupNames api call, it returns success if at least one name could be resolved. If an account couldn't be resolved, the use flag has the value 8 (SidTypeUnknown). =item LsaLookupSids(\$server, $\backslash{}$@sids, $\backslash{}$@info) Looks up for sid's and returns the appropriate names, domains, sid's and domain sid's. Unlike to the LsaLookupsids api call, it returns success if at least one sid could be resolved. If a sid couldn't be resolved, the use flag has the value 7 (SidTypeInvalid) or 8 (SidTypeUnknown). =item LsaEnumerateAccountsWithUserRight(\$server, \$privilege, $\backslash{}$@sids) Enumerates all sids granted a privilege. To convert sid's to account names use LsaLookupSids. If the privilege is not granted to anybody, the error code is 259. This is not an error, it's by design. =item LsaEnumerateAccountRights(\$server, \$sid, $\backslash{}$@privileges) Enumerates all privileges granted to a sid. To convert account names to sid's use LsaLookupNames. If the sid has not granted any privileges, the error code is 2. This is not an error, it's by design. =item LsaAddAccountRights(\$server, \$sid, $\backslash{}$@privileges) Grants privileges to a sid. To convert account names to sid's use LsaLookupNames. Be really carefully with the sid. If the sid does not belong to a user, LsaAddAccountRights creates a new user without a user name. =item LsaRemoveAccountRights(\$server, \$sid, $\backslash{}$@privileges, {\tt [}\$all{\tt ]}) Removes privileges from a sid. To convert account names to sid's use LsaLookupNames. If the optional parameter \$all is not null, all privileges for \$sid will be removed. In this case, @privileges has no meaning. Note: there is a mistake in the documentation from Microsoft (see the platform sdk). If you remove all privileges with the \$all parameter the account won't be deleted. =item LsaQueryTrustedDomainInfo(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Queries information about trusted domains. Don't call LsaQueryTrustedDomainInfo directly. Use the wrappers LsaQueryTrustedXXXInfo instead. =item LsaSetTrustedDomainInformation(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Sets information about trusted domains. Don't call LsaSetTrustedDomainInformation directly. Use the wrappers LsaSetTrustedXXXInfo instead. =item LsaSetTrustedDomainInfo(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Sets information about trusted domains. Don't call LsaSetTrustedDomainInfo directly. Use the wrappers LsaSetTrustedXXXInfo instead. =item LsaQueryTrustedDomainNameInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the domain name info for a trusted domain. =item LsaSetTrustedDomainNameInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the domain name info for a trusted domain. If the specified domain is not in the list of trusted domains, the function adds it. =item LsaQueryTrustedPosixOffsetInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the posix rid used to create posix users or groups for a trusted domain. =item LsaSetTrustedPosixOffsetInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the posix rid used to create posix users or groups for a trusted domain. =item LsaQueryTrustedPasswordInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the passwords used by trust connections for a trusted domain. =item LsaSetTrustedPasswordInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the passwords used by trust connections for a trusted domain. =item LsaRetrievePrivateData(\$server, \$key, $\backslash{}$\$data) Retrieves private data that was stored by the LsaStorePrivateData. =item LsaStorePrivateData(\$server, \$key, $\backslash{}$\$data) Stores or deletes private data under a specified registry key. =item GrantPrivilegeToAccount(\$server, \$privilege, $\backslash{}$@accounts) Grants a privilege to users and/or groups. Avoid using GrantPrivilegeToAccount. Use LsaAddAccountRights instead. =item RevokePrivilegeFromAccount(\$server, \$privilege, $\backslash{}$@accounts) Revokes a privilege from users and/or groups. Avoid using RevokePrivilegeFromAccount. Use LsaRemoveAccountRights instead. =item EnumAccountPrivileges(\$server, \$account, $\backslash{}$@privileges) Enumerates privileges held by an user or group. If the user has not granted any privileges, the error code is 2. This is not an error, it's by design. Avoid using EnumAccountPrivileges. Use LsaEnumerateAccountRights instead. =item EnumPrivilegeAccounts(\$server, \$privilege, $\backslash{}$@accounts) Enumerates all accounts (users and groups) granted a privilege. If the privilege is not granted to anybody, the error code is 259. This is not a bug, it is by design. Avoid using EnumPrivilegeAccounts. Use LsaEnumerateAccountsWithUserRight instead. =back =head2 Policy and Privileges (LSA) EXAMPLES: =over 4 =item LsaQueryInformationPolicy(\$server, \$infotype, $\backslash{}$\%info) Queries the audit log policies on server $\backslash{}$$\backslash{}$testserver. Don't call LsaQueryInformationPolicy directly. Use the wrappers LsaQueryXXXPolicy instead (see examples below). if(!Win32::Lanman::LsaQueryInformationPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&PolicyAuditLogInformation, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetInformationPolicy(\$server, \$infotype, $\backslash{}$\%info) Sets the audit log policies on server $\backslash{}$$\backslash{}$testserver. Don't call LsaSetInformationPolicy directly. Use the wrappers LsaSetXXXPolicy instead (see examples below). \#events to audit \$options{\tt [}AuditCategorySystem{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}UNCHANGED; \$options{\tt [}AuditCategoryLogon{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}SUCCESS; \$options{\tt [}AuditCategoryObjectAccess{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}FAILURE; \$options{\tt [}AuditCategoryPrivilegeUse{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryDetailedTracking{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}SUCCESS $|$ \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}FAILURE; \$options{\tt [}AuditCategoryPolicyChange{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryAccountManagement{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \# only valid in nt 5 \$options{\tt [}AuditCategoryDirectoryServiceAccess{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryAccountLogon{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \%info = ('auditingmode' =$>$ 1, \# turn on auditing 'eventauditingoptions' =$>$ $\backslash{}$@options \# events to audit ); if(!Win32::Lanman::LsaSetInformationPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", PolicyAuditEventsInformation, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryAuditLogPolicy(\$server, $\backslash{}$\%info) Queries the audit log policies on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryAuditLogPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaQueryAuditEventsPolicy(\$server, $\backslash{}$\%info) Queries the audit event policies on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryAuditLogPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "auditingmode=\$info\{auditingmode\}$\backslash{}$n"; print "maximumauditeventcount=\$info\{maximumauditeventcount\}$\backslash{}$n"; print "eventauditingoptions:$\backslash{}$n"; if(\$info\{maximumauditeventcount\} $>$ 0) \{ \$options = \$info\{eventauditingoptions\}; foreach \$option (@\$options) \{ print "$\backslash{}$t\$option$\backslash{}$n"; \} \} =item LsaSetAuditEventsPolicy(\$server, $\backslash{}$\%info) Sets audit event policy information on server $\backslash{}$$\backslash{}$testserver. \#events to audit \$options{\tt [}AuditCategorySystem{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}UNCHANGED; \$options{\tt [}AuditCategoryLogon{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}SUCCESS; \$options{\tt [}AuditCategoryObjectAccess{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}FAILURE; \$options{\tt [}AuditCategoryPrivilegeUse{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryDetailedTracking{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}SUCCESS $|$ \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}FAILURE; \$options{\tt [}AuditCategoryPolicyChange{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryAccountManagement{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \# only valid in nt 5 \$options{\tt [}AuditCategoryDirectoryServiceAccess{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \$options{\tt [}AuditCategoryAccountLogon{\tt ]} = \&POLICY\underscore{}AUDIT\underscore{}EVENT\underscore{}NONE; \%info = ('auditingmode' =$>$ 1, \# turn on auditing 'eventauditingoptions' =$>$ $\backslash{}$@options \# events to audit ); if(!Win32::Lanman::LsaSetAuditEventsPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryPrimaryDomainPolicy(\$server, $\backslash{}$\%info) Queries primary domain policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryPrimaryDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "name=\$info\{name\}$\backslash{}$n"; print "sid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{sid\}), \$info\{sid\}), "$\backslash{}$n"; =item LsaSetPrimaryDomainPolicy(\$server, $\backslash{}$\%info) Sets the primary domain policy information for server $\backslash{}$$\backslash{}$testserver2 to the same like server $\backslash{}$$\backslash{}$testserver1. if(!Win32::Lanman::LsaQueryPrimaryDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver1", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "name=\$info\{name\}$\backslash{}$n"; print "sid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{sid\}), \$info\{sid\}), "$\backslash{}$n"; if(!Win32::Lanman::LsaSetPrimaryDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver2", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryPdAccountPolicy(\$server, $\backslash{}$\%info) Queries the primary domain account used for authentication and lookup requests on server $\backslash{}$$\backslash{}$testserver. It returns always an empty string. This should be a bug in the call. if(!Win32::Lanman::LsaQueryPdAccountPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaQueryAccountDomainPolicy(\$server, $\backslash{}$\%info) Queries account domain policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryAccountDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "domainname=\$info\{domainname\}$\backslash{}$n"; print "domainsid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{domainsid\}), \$info\{domainsid\}), "$\backslash{}$n"; =item LsaSetAccountDomainPolicy(\$server, $\backslash{}$\%info) Sets account domain policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryAccountDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "domainname=\$info\{domainname\}$\backslash{}$n"; print "domainsid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{domainsid\}), \$info\{domainsid\}), "$\backslash{}$n"; \$info\{domainname\} = 'testserver2'; if(!Win32::Lanman::LsaSetAccountDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryServerRolePolicy(\$server, $\backslash{}$\%info) Queries server role policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryServerRolePolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetServerRolePolicy(\$server, $\backslash{}$\%info) Sets server role policy information to PolicyServerRoleBackup on server $\backslash{}$$\backslash{}$testserver. \%info = (serverrole => \&PolicyServerRoleBackup); if(!Win32::Lanman::LsaQueryServerRolePolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryReplicaSourcePolicy(\$server, $\backslash{}$\%info) Queries replication source server on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryReplicaSourcePolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetReplicaSourcePolicy(\$server, $\backslash{}$\%info) Sets replication source server to $\backslash{}$$\backslash{}$testserver2 on server $\backslash{}$$\backslash{}$testserver. \$info\{replicasource\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver2"; if(!Win32::Lanman::LsaSetReplicaSourcePolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryDefaultQuotaPolicy(\$server, $\backslash{}$\%info) Queries the default quota policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryDefaultQuotaPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaQueryDefaultQuotaPolicy(\$server, $\backslash{}$\%info) Sets the default quota policy information on server $\backslash{}$$\backslash{}$testserver (doubles the minimum working set size). if(!Win32::Lanman::LsaQueryDefaultQuotaPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \$info\{minimumworkingsetsize\} $\ast$= 2; if(!Win32::Lanman::LsaSetDefaultQuotaPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryAuditFullPolicy(\$server, $\backslash{}$\%info) Queries the audit full policy information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaQueryAuditFullPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetAuditFullPolicy(\$server, $\backslash{}$\%info) Sets the audit full policy information on server $\backslash{}$$\backslash{}$testserver. The server will shut down, if the audit log is full. if(!Win32::Lanman::LsaSetAuditFullPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{shutdownonfull =$>$ 1\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryDnsDomainPolicy(\$server, $\backslash{}$\%info) Queries the dns domain policy information on server $\backslash{}$$\backslash{}$testserver. This call is only supported in nt 5 and is currently untested! if(!Win32::Lanman::LsaQueryDnsDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "name=\$info\{name\}$\backslash{}$n"; print "dnsdomainname=\$info\{dnsdomainname\}$\backslash{}$n"; print "dnsforestname=\$info\{dnsforestname\}$\backslash{}$n"; print "guid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{guid\}), \$info\{guid\}), "$\backslash{}$n"; print "sid=", unpack("H" . 2 $\ast$ {\em length\/}(\$info\{sid\}), \$info\{sid\}), "$\backslash{}$n"; =item LsaQueryDnsDomainPolicy(\$server, $\backslash{}$\%info) Sets the dns domain policy information on server $\backslash{}$$\backslash{}$testserver. This call is only supported in nt 5 and is currently untested! if(!Win32::Lanman::LsaQueryDnsDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \#\$info\{dnsdomainname\} = ... \#\$info\{dnsforestname\} = ... if(!Win32::Lanman::LsaSetDnsDomainPolicy("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaEnumerateTrustedDomains(\$server, $\backslash{}$@domains) Shows the domain name and sid of your workstation. If you call this on any domain controller, you'll get a list of trusted domains (see the example below). if(!Win32::Lanman::LsaEnumerateTrustedDomains("", $\backslash{}$@domains)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em domain\/}(@domains) \{ print "name=\$\{\$domain\}\{name\}$\backslash{}$t"; print "sid=" . unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$domain\}\{sid\}), \$\{\$domain\}\{sid\}) . "$\backslash{}$n"; \} Enumerates all trusted domains of the domain testdomain. if(!Win32::Lanman::NetGetDCName("", "testdomain", $\backslash{}$\$pdcname)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaEnumerateTrustedDomains(\$pdcname, $\backslash{}$@domains)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em domain\/}(@domains) \{ print "name=\$\{\$domain\}\{name\}$\backslash{}$t"; print "sid=" . Win32::Lanman::{\em SidToString\/}(\$\{\$domain\}\{sid\}) . "$\backslash{}$n"; \} Enumerate all Trusted domains for your workstation if(!Win32::Lanman::LsaEnumerateTrustedDomains("", $\backslash{}$@domains)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach my \$domain (@domains) \{ next unless Win32::Lanman::NetGetAnyDCName("", \$\{\$domain\}\{name\},$\backslash{}$\$prim\underscore{}dom\underscore{}dcname); print "name=\$\{\$domain\}\{name\}, anydc=\$prim\underscore{}dom\underscore{}dcname$\backslash{}$n"; next unless Win32::Lanman::LsaEnumerateTrustedDomains(\$prim\underscore{}dom\underscore{}dcname, $\backslash{}$@trusts); foreach \${\em trust\/}(@trusts) \{ next unless Win32::Lanman::NetGetAnyDCName(\$prim\underscore{}dom\underscore{}dcname, \$\{\$trust\}\{name\}, $\backslash{}$\$dcname); print "\$prim\underscore{}dom\underscore{}dcname Trusts name=\$\{\$trust\}\{name\}, anydc=\$dcname$\backslash{}$n"; \} \} =item LsaLookupNames(\$server, $\backslash{}$@accounts, $\backslash{}$@info) Looks up for account names in @account on server $\backslash{}$$\backslash{}$testserver and returns the appropriate rid, domains, sid's and domain sid's. @accounts = ('user1', 'user2', 'group1', 'testdomain$\backslash{}$$\backslash{}$group2'); if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", @accounts, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$info (@infos) \{ print "name=", \$accounts{\tt [}\$count++{\tt ]}, "$\backslash{}$n"; @keys = sort keys \%\$info; foreach \${\em key\/}(@keys) \{ if(\$key eq "domainsid" $|$$|$ \$key eq "sid") \{ print "\$key=" . unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$info\}\{\$key\}), \$\{\$info\}\{\$key\}) . "$\backslash{}$n"; \} else \{ print "\$key=\$\{\$info\}\{\$key\}$\backslash{}$n"; \} \} \} =item LsaLookupSids(\$server, $\backslash{}$@sids, $\backslash{}$@info) Looks up for sid's in @sids on server $\backslash{}$$\backslash{}$testserver and returns the appropriate account names, domains, sid's and domain sid's. @sids = ( pack("C12", 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), \#everyone pack("C12", 1, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0), \#local pack("C12", 1, 1, 0, 0, 0, 0, 0, 5, 2, 0, 0, 0), \#network pack("C12", 1, 1, 0, 0, 0, 0, 0, 5, 3, 0, 0, 0), \#batch pack("C12", 1, 1, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0), \#service pack("C12", 1, 1, 0, 0, 0, 0, 0, 5, 3, 0, 0, 0), \#batch pack("C16", 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0 ,0), \#administrators pack("C16", 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 33, 2, 0 ,0), \#users pack("C16", 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 34, 2, 0 ,0) \#guests ); if(!Win32::Lanman::LsaLookupSids("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@sids, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$info (@infos) \{ print "sid=" . unpack("H" . 2 $\ast$ {\em length\/}(\$sids{\tt [}\$count{\tt ]}), \$sids{\tt [}\$count++{\tt ]}) . "$\backslash{}$n"; @keys = sort keys \%\$info; foreach \${\em key\/}(@keys) \{ if(\$key eq "domainsid") \{ print "\$key=" . unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$info\}\{\$key\}), \$\{\$info\}\{\$key\}) . "$\backslash{}$n"; \} else \{ print "\$key=\$\{\$info\}\{\$key\}$\backslash{}$n"; \} \} \} =item LsaEnumerateAccountsWithUserRight(\$server, \$privilege, $\backslash{}$@sids) Enums all accounts granted the SeNetworkLogonRight privilege on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaEnumerateAccountsWithUserRight("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&SE\underscore{}NETWORK\underscore{}LOGON\underscore{}NAME, $\backslash{}$@sids)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaLookupSids("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@sids, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$info (@infos) \{ @keys = sort keys \%\$info; foreach \${\em key\/}(@keys) \{ if(\$key eq "domainsid" $|$$|$ \$key eq "sid") \{ print "\$key=" . unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$info\}\{\$key\}), \$\{\$info\}\{\$key\}) . "$\backslash{}$n"; \} else \{ print "\$key=\$\{\$info\}\{\$key\}$\backslash{}$n"; \} \} \} =item LsaEnumerateAccountRights(\$server, \$sid, $\backslash{}$@privileges) Enumerates all privileges granted to the account testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testuser'{\tt ]}, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaEnumerateAccountRights("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$infos{\tt [}0{\tt ]}\}\{sid\}, $\backslash{}$@privileges)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em priv\/}(@privileges) \{ print "\$priv$\backslash{}$n"; \} =item LsaAddAccountRights(\$server, \$sid, $\backslash{}$@privileges) Grants privileges SeBackupPrivilege, SeRestorePrivilege, SeShutdownPrivilege and SeDebugPrivilege to user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testuser'{\tt ]}, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaAddAccountRights("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$infos{\tt [}0{\tt ]}\}\{sid\}, {\tt [}\&SE\underscore{}BACKUP\underscore{}NAME, \&SE\underscore{}RESTORE\underscore{}NAME, \&SE\underscore{}SHUTDOWN\underscore{}NAME, \&SE\underscore{}DEBUG\underscore{}NAME{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaRemoveAccountRights(\$server, \$sid, $\backslash{}$@privileges, {\tt [}\$all{\tt ]}) Removes the privileges SeBackupPrivilege, SeRestorePrivilege, SeShutdownPrivilege and SeDebugPrivilege from the user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testuser'{\tt ]}, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaRemoveAccountRights("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$infos{\tt [}0{\tt ]}\}\{sid\}, {\tt [}\&SE\underscore{}BACKUP\underscore{}NAME, \&SE\underscore{}RESTORE\underscore{}NAME, \&SE\underscore{}SHUTDOWN\underscore{}NAME, \&SE\underscore{}DEBUG\underscore{}NAME{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Removes all privileges from the user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testuser'{\tt ]}, $\backslash{}$@infos)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaRemoveAccountRights("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$infos{\tt [}0{\tt ]}\}\{sid\}, {\tt [}{\tt ]}, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code \#print print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryTrustedDomainInfo(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Queries the trusted domain passwords for domain testdomain on server $\backslash{}$$\backslash{}$testserver. Don't call LsaQueryTrustedDomainInfo directly. Use the wrappers LsaQueryTrustedXXXInfo instead (see examples below). if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaQueryTrustedDomainInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \&TrustedPasswordInformation, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "password=" . unpack("H" . 2 $\ast$ {\em length\/}(\$info\{password\}), \$info\{password\}) . "$\backslash{}$n"; print "oldpassword=" . unpack("H" . 2 $\ast$ {\em length\/}(\$info\{oldpassword\}), \$info\{oldpassword\}) . "$\backslash{}$n"; =item LsaSetTrustedDomainInformation(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Sets the trusted domain passwords for domain testdomain on server $\backslash{}$$\backslash{}$testserver to newpassword. Don't call LsaSetTrustedDomainInformation directly. Use the wrappers LsaQueryTrustedXXXInfo instead (see examples below). if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaSetTrustedDomainInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \&TrustedPasswordInformation, \{ password =$>$ 'newpassword'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaSetTrustedDomainInfo(\$server, \$domainsid, \$infotype, $\backslash{}$\%info) Sets the trusted domain passwords for domain testdomain on server $\backslash{}$$\backslash{}$testserver to newpassword. Don't call LsaSetTrustedDomainInfo directly. Use the wrappers LsaQueryTrustedXXXInfo instead (see examples below). if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaSetTrustedDomainInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \&TrustedPasswordInformation, \{ password =$>$ 'newpassword'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryTrustedDomainNameInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the domain name info for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaQueryTrustedDomainNameInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetTrustedDomainNameInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the trusted domain name for testdomain on the domain $\backslash{}$$\backslash{}$testserver belongs to. If testdomain isn't already a member of the trusted domain list, the function adds it. Keep in mind, this function is not tested completely. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaSetTrustedDomainNameInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \{name =$>$ 'testdomain'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryTrustedPosixOffsetInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the posix rid used to create posix users or groups for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaQueryTrustedPosixOffsetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item LsaSetTrustedPosixOffsetInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the posix rid used to create posix users or groups for domain testdomain on server $\backslash{}$$\backslash{}$testserver to the value 123456. You should use this function only, if you really know what you're doing! Keep in mind, this function is not tested completely. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaSetTrustedPosixOffsetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \{offset =$>$ 123456\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaQueryTrustedPasswordInfo(\$server, \$domainsid, $\backslash{}$\%info) Queries the trusted domain passwords for domain testdomain on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaQueryTrustedPasswordInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "password=" . unpack("H" . 2 $\ast$ {\em length\/}(\$info\{password\}), \$info\{password\}) . "$\backslash{}$n"; print "oldpassword=" . unpack("H" . 2 $\ast$ {\em length\/}(\$info\{oldpassword\}), \$info\{oldpassword\}) . "$\backslash{}$n"; =item LsaSetTrustedPasswordInfo(\$server, \$domainsid, $\backslash{}$\%info) Sets the trusted domain passwords for domain testdomain on server $\backslash{}$$\backslash{}$testserver to newpassword. You should use this function only, if you really know what you're doing! Keep in mind, this function is not tested completely. if(!Win32::Lanman::LsaLookupNames("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", {\tt [}'testdomain'{\tt ]}, $\backslash{}$@domain)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::LsaSetTrustedPasswordInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$domain{\tt [}0{\tt ]}\}\{domainsid\}, \{ password =$>$ 'newpassword'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item LsaRetrievePrivateData(\$server, \$key, $\backslash{}$\$data) Retrieves private data (here the encrypted machine password --- \$MACHINE.ACC) that was stored by the LsaStorePrivateData function on server $\backslash{}$$\backslash{}$testserver. For further information about global, local and machine objects, see also the LsaRetrievePrivateData function in the MSDN (topic private data object). if(!Win32::Lanman::LsaRetrievePrivateData("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$\$MACHINE.ACC", $\backslash{}$\$data)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$data; =item LsaStorePrivateData(\$server, \$key, $\backslash{}$\$data) Stores private data (here the encrypted machine password --- \$MACHINE.ACC) on server $\backslash{}$$\backslash{}$testserver. For further information about global, local and machine objects, see also the LsaStorePrivateData function in the MSDN (topic private data object). You should use this function only, if you really know what you're doing! Keep in mind, this function is not tested completely. if(!Win32::Lanman::LsaStorePrivateData("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$\$MACHINE.ACC", 'new\underscore{}machine\underscore{}pwd')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item GrantPrivilegeToAccount(\$server, \$privilege, $\backslash{}$@accounts) Grants the SeShutdownPrivilege to users testuser1, testuser1 and group testgroup on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::GrantPrivilegeToAccount("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&SE\underscore{}SHUTDOWN\underscore{}NAME, {\tt [}"testuser1", "testuser2", "testgroup"{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item RevokePrivilegeFromAccount(\$server, \$privilege, $\backslash{}$@accounts) Revokes the SeServiceLogonRight from users testuser1, testuser1 and group testgroup on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::RevokePrivilegeToAccount("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&SE\underscore{}SERVICE\underscore{}LOGON\underscore{}NAME, {\tt [}"testuser1", "testuser2", "testgroup"{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item EnumAccountPrivileges(\$server, \$account, $\backslash{}$@privileges) Enums all privileges held by an user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumAccountPrivileges("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", $\backslash{}$@privileges)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach (@privileges) \{ print "\$\underscore{}$\backslash{}$n"; \} =item EnumPrivilegeAccounts(\$server, \$privilege, $\backslash{}$@accounts) Enums all accounts granted the privilege SE\underscore{}INTERACTIVE\underscore{}LOGON\underscore{}NAME on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumAccountPrivileges("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&SE\underscore{}INTERACTIVE\underscore{}LOGON\underscore{}NAME, $\backslash{}$@accounts)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach (@accounts) \{ print "\$\underscore{}$\backslash{}$n"; \} =back =head2 File System Replicator =over 4 =item NetReplExportDirAdd(\$server, $\backslash{}$\%info) Registers an existing directory in the export path to be replicated. =item NetReplExportDirDel(\$server, \$directory) Removes registration of a replicated directory. =item NetReplExportDirEnum(\$server, $\backslash{}$@directories) Lists the replicated directories in the export path. =item NetReplExportDirGetInfo(\$server, \$directory, $\backslash{}$\%info) Retrieves the control information of a replicated directory. =item NetReplExportDirLock(\$server, \$directory) Locks a replicated directory. =item NetReplExportDirSetInfo(\$server, \$directory, $\backslash{}$\%info) Modifies the control information of a replicated directory. =item NetReplExportDirUnlock(\$server, \$directory, {\tt [}\$forceUnlock{\tt ]}) Unlocks a replicated directory. =item NetReplGetInfo(\$server, $\backslash{}$\%info) Retrieves configuration information for the Replicator service. =item NetReplImportDirAdd(\$server, \$directory) Registers an existing directory in the import path to be replicated. =item NetReplImportDirDel(\$server, \$directory) Removes registration of a replicated directory. =item NetReplImportDirEnum(\$server, $\backslash{}$@directories) Lists the replicated directories in the import path. =item NetReplImportDirGetInfo(\$server, \$directory, $\backslash{}$\%info) Retrieves the control information of a replicated directory. =item NetReplImportDirLock(\$server, \$directory) Locks a replicated directory. =item NetReplImportDirUnlock(\$server, \$directory, {\tt [}\$forceUnlock{\tt ]}) Unlocks a replicated directory. =item NetReplSetInfo(\$server, $\backslash{}$\%info) Modifies the Replicator service configuration information. =back =head2 File System Replicator EXAMPLES: =over 4 =item NetReplExportDirAdd(\$server, $\backslash{}$\%info) Registers an existing directory testexportdir in the export path of server $\backslash{}$$\backslash{}$testserver to be replicated. if(!Win32::Lanman::NetReplExportDirAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{'dirname' =$>$ "testexportdir", 'integrity' =$>$ \&REPL\underscore{}INTEGRITY\underscore{}FILE, 'extent' =$>$ \&REPL\underscore{}EXTENT\underscore{}TREE\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplExportDirDel(\$server, \$directory) Removes registration of replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplExportDirEnum(\$server, $\backslash{}$@directories) Lists the replicated directories in the export path on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@directories)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$directory (@directories) \{ @keys = sort keys \%\$directory; foreach \$key (@keys) \{ print "\$key=\$\{\$directory\}\{\$key\}$\backslash{}$n"; \} \} =item NetReplExportDirGetInfo(\$server, \$directory, $\backslash{}$\%info) Retrieves the control information of the replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \$key (@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetReplExportDirLock(\$server, \$directory) Adds a lock to the replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirLock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplExportDirSetInfo(\$server, \$directory, $\backslash{}$\%info) Modifies the control information of the replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir", \{'dirname' =$>$ "testexportdir", 'integrity' =$>$ \&REPL\underscore{}INTEGRITY\underscore{}FILE, 'extent' =$>$ \&REPL\underscore{}EXTENT\underscore{}FILE\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplExportDirUnlock(\$server, \$directory, {\tt [}\$forceUnlock{\tt ]}) Decrements the lock counter by one for the replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirUnlock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Sets the lock counter to zero for the replicated directory testexportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplExportDirUnlock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testexportdir", REPL\underscore{}UNLOCK\underscore{}FORCE)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplGetInfo(\$server, $\backslash{}$\%info) Retrieves configuration information for the Replicator service on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \$key (@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetReplImportDirAdd(\$server, \$directory) Registers an existing directory testimportdir in the import path of server $\backslash{}$$\backslash{}$testserver to be replicated. if(!Win32::Lanman::NetReplImportDirAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$terstserver", "testimportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplImportDirDel(\$server, \$directory) Removes registration of replicated directory testimportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testimportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplImportDirEnum(\$server, $\backslash{}$@directories) Lists the replicated directories in the import path on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@directories)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$directory (@directories) \{ @keys = keys \%\$directory; foreach \$key (@keys) \{ print "\$key=\$\{\$directory\}\{\$key\}$\backslash{}$n"; \} \} =item NetReplImportDirGetInfo(\$server, \$directory, $\backslash{}$\%info) Retrieves the control information of the replicated directory testimportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testimportdir", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \$key (@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetReplImportDirLock(\$server, \$directory) Adds a lock to the replicated directory testimportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirLock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testimportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplImportDirUnlock(\$server, \$directory, {\tt [}\$forceUnlock{\tt ]}) Decrements the lock counter by one for the replicated directory testimportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirUnlock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testimportdir")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Sets the lock counter to zero for the replicated directory testimportdir on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplImportDirUnlock("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testimportdir", REPL\underscore{}UNLOCK\underscore{}FORCE)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetReplSetInfo(\$server, $\backslash{}$\%info) Modifies the Replicator service configuration information on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetReplSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{role =$>$ REPL\underscore{}ROLE\underscore{}BOTH, exportpath =$>$ "c:$\backslash{}$$\backslash{}$winnt$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$repl$\backslash{}$$\backslash{}$export", exportlist =$>$ 'testexpdomain', importpath =$>$ "c:$\backslash{}$$\backslash{}$winnt$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$repl$\backslash{}$$\backslash{}$import", importlist =$>$ 'testimpdomain', logonusername =$>$ '', interval =$>$ 10, pulse =$>$ 2, guardtime =$>$ 5, random =$>$ 120\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Schedule =over 4 =item NetScheduleJobAdd(\$server, $\backslash{}$\%info) Submits a job to run at a specified future time and date. =item NetScheduleJobDel(\$server, \$minjobid, \$maxjobid) Deletes a range of jobs queued to run at a computer. =item NetScheduleJobEnum(\$server, $\backslash{}$@info) Lists the jobs queued on a specified computer. =item NetScheduleJobGetInfo(\$server, $\backslash{}$@info) Retrieves information about a particular job queued on a specified computer. =back =head2 Schedule EXAMPLES: =over 4 =item NetScheduleJobAdd(\$server, $\backslash{}$\%info) Submits a job to run at at 12 o'clock noon on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetScheduleJobAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{jobtime =$>$ 12 $\ast$ 3600 $\ast$ 1000, daysofmonth =$>$ 0, daysofmonth =$>$ 0, daysofweek =$>$ 0, flags =$>$ 0, command =$>$ "winfile.exe"\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$info\{jobid\}; =item NetScheduleJobDel(\$server, \$minjobid, \$maxjobid) Deletes all jobs between job id's 5 to 10 on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetScheduleJobDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 5, 10)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetScheduleJobEnum(\$server, $\backslash{}$@info) Lists the job properties of all jobs queued on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetScheduleJobEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@jobs)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$job (@jobs) \{ @keys = keys \%\$job; foreach \$key (@keys) \{ print "\$key=\$\{\$job\}\{\$key\}$\backslash{}$n"; \} \} =item NetScheduleJobGetInfo(\$server, $\backslash{}$@info) Retrieves information about job 5 queued on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetScheduleJobGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 5, $\backslash{}$\%job)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%job; foreach \$key (@keys) \{ print "\$key=\$job\{\$key\}$\backslash{}$n"; \} =back =head2 Server =over 4 =item NetServerDiskEnum(\$server, $\backslash{}$@info) Retrieves a list of disk drives on a server. =item NetServerEnum(\$server, \$domain, \$type, $\backslash{}$@info) Lists all servers of the specified type that are visible in the specified domain. \$type can be any of the constants SV\underscore{}TYPE\underscore{}$\ast$. e.g. SV\underscore{}TYPE\underscore{}SQLSERVER , SV\underscore{}TYPE\underscore{}TERMINALSERVER , SV\underscore{}TYPE\underscore{}NT . These can also be combined using $|$. To get all SQL servers or terminal servers user \$type = SV\underscore{}TYPE\underscore{}SQLSERVER $|$ SV\underscore{}TYPE\underscore{}TERMINALSERVER =item NetServerGetInfo(\$server, $\backslash{}$\%info, {\tt [}\$fullinfo{\tt ]}) Retrieves information about the specified server. =item NetServerSetInfo(\$server, $\backslash{}$\%info, {\tt [}\$fullinfo{\tt ]}) Sets a server’s operating parameters. =item NetServerTransportAdd(\$server, $\backslash{}$\%info) Binds the server to the transport. =item NetServerTransportDel(\$server, $\backslash{}$\%info) Unbinds (or disconnects) the transport protocol from the server. =item NetServerTransportEnum(\$server, $\backslash{}$@info) Supplies information about transports that are managed by the server. =back =head2 Server EXAMPLES: =over 4 =item NetServerDiskEnum(\$server, $\backslash{}$@info) Retrieves a list of disk drives on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerDiskEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@disks)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$disk (@disks) \{ print "\$disk$\backslash{}$n"; \} =item NetServerEnum(\$server, \$domain, \$type, $\backslash{}$@info) Lists all servers of the type SV\underscore{}TYPE\underscore{}NT that are visible in the domain testdomain. The command will be executed on $\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testdomain", SV\underscore{}TYPE\underscore{}NT, $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$server (@info) \{ @keys = keys \%\$server; foreach \${\em key\/}(@keys) \{ print "\$key=\$\{\$server\}\{\$key\}$\backslash{}$n"; \} \} =item NetServerGetInfo(\$server, $\backslash{}$\%info, {\tt [}\$fullinfo{\tt ]}) Retrieves basic and extended information about the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} Retrieves only basic information about the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetServerSetInfo(\$server, $\backslash{}$\%info, {\tt [}\$fullinfo{\tt ]}) Changes the server’s operating parameters userpath to c:$\backslash{}$users and hidden to true on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \$info\{'hidden'\} = 1; \$info\{'userpath'\} = "c:$\backslash{}$$\backslash{}$users"; if(!Win32::Lanman::NetServerSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetServerTransportAdd(\$server, $\backslash{}$\%info) Binds the server to the transport on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerTransportAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{'domain' =$>$ 'testdomain', 'networkaddress' =$>$ '000000000000', 'numberofvcs' =$>$ 0, 'transportaddress' =$>$ 'TESTSERVER', 'transportaddresslength' =$>$ {\em length\/}('TESTSERVER'), 'transportname' =$>$ "$\backslash{}$$\backslash{}$Device$\backslash{}$$\backslash{}$NetBT\underscore{}NdisWan7" \})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetServerTransportDel(\$server, $\backslash{}$\%info) Unbinds (or disconnects) the transport protocol on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerTransportDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{'domain' =$>$ 'testdomain', 'networkaddress' =$>$ '000000000000', 'numberofvcs' =$>$ 0, 'transportaddress' =$>$ 'TESTSERVER', 'transportaddresslength' =$>$ {\em length\/}('TESTSERVER'), 'transportname' =$>$ "$\backslash{}$$\backslash{}$Device$\backslash{}$$\backslash{}$NetBT\underscore{}NdisWan7" \})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetServerTransportEnum(\$server, $\backslash{}$@info) Supplies information about transports that are managed by the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetServerTransportEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$server (@info) \{ @keys = keys \%\$server; foreach \${\em key\/}(@keys) \{ print "\$key=\#\$\{\$server\}\{\$key\}\#$\backslash{}$n"; \} \} =back =head2 Session =over 4 =item NetSessionDel(\$server, \$client, \$user) Ends a session between a server and a workstation. =item NetSessionEnum(\$server, \$client, \$user, $\backslash{}$@info) Provides information about all current sessions. =item NetSessionGetInfo(\$server, \$client, \$user, $\backslash{}$\%info) Retrieves information about a session established . =back =head2 Session EXAMPLES: =over 4 =item NetSessionDel(\$server, \$client, \$user) Ends all session on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetSessionDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', '')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Ends the session on server $\backslash{}$$\backslash{}$testserver to client $\backslash{}$$\backslash{}$testclient for user testuser. if(!Win32::Lanman::NetSessionDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testclient", "testuser")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetSessionEnum(\$server, \$client, \$user, $\backslash{}$@info) Provides information about all current sessions on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetSessionEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", "", $\backslash{}$@sessions)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$session (@sessions) \{ @keys = keys \%\$session; foreach \${\em key\/}(@keys) \{ print "\$key=\#\$\{\$session\}\{\$key\}\#$\backslash{}$n"; \} \} Provides information about the current sessions for client $\backslash{}$$\backslash{}$testclient and user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetSessionEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testclient", "testuser", $\backslash{}$@sessions)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$session (@sessions) \{ @keys = keys \%\$session; foreach \$key (@keys) \{ print "\$key=\#\$\{\$session\}\{\$key\}\#$\backslash{}$n"; \} \} =item NetSessionGetInfo(\$server, \$client, \$user, $\backslash{}$\%info) Retrieves information about a session on server $\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver for client $\backslash{}$$\backslash{}$testclient. if(!Win32::Lanman::NetSessionGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testclient", "", $\backslash{}$\%session)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%session; foreach \$key (@keys) \{ print "\$key=\$session\{\$key\}$\backslash{}$n"; \} =back =head2 Share In the following section on shares. Information about a share is stored in a hash (\%shareinfo). The following are valid keys: netname, type, remark, permissions, max\underscore{}uses, current\underscore{}uses, path, passwd and security\underscore{}descriptor (which is has a binary value) =over 4 =item NetShareAdd(\$server, $\backslash{}$\%shareinfo) Adds a new share on \$server. =item NetShareCheck(\$server, \$path, $\backslash{}$\$type) Checks whether or not a \$server is sharing a device. =item NetShareDel(\$server, \$share) Deletes a share from \$server. =item NetShareEnum(\$server, $\backslash{}$@shares) Enumerates all shares on \$server. =item NetShareGetInfo(\$server, \$share, $\backslash{}$\%info) Gets information about \$share on \$server, the results are stored in \%info =item NetShareSetInfo(\$server, \$share, $\backslash{}$\%info) Sets information about \$share on \$server as specified in \%info. =item NetConnectionEnum(\$server, \$share\underscore{}or\underscore{}computer, $\backslash{}$\%connections) Gets all connections made to a shared resource on the server \$server or all connections established from a particular computer. If \$share\underscore{}or\underscore{}computer has two backslashes befor the name it is interpreted as a computer name, otherwise as a share name. =back =head2 Share EXAMPLES: =over 4 =item NetShareAdd(\$server, $\backslash{}$\%shareinfo) Adds a new share on server $\backslash{}$$\backslash{}$testdfsserver. If you want to set security, you have to build a security descriptor. \$secdesc = ... if(!Win32::Lanman::NetShareAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testdfsserver", \{'netname' =$>$ 'testshare', \# share name type =$>$ Win32::Lanman::STYPE\underscore{}DISKTREE, \# share type remark =$>$ 'remark for testshare', \# remark permissions =$>$ 0, \# only used for share level security max\underscore{}uses =$>$ 5, \# number of users can connect current\underscore{}uses =$>$ 0, \# unused path =$>$ 'c:$\backslash{}$test', \# physical share path passwd =$>$ 'password', \# password security\underscore{}descriptor =$>$ \$secdesc\})) \# sec. descriptor if you need security \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetShareCheck(\$server, \$path, $\backslash{}$\$type) Checks if c:$\backslash{}$test on server $\backslash{}$$\backslash{}$testserver is sharing a device. if(!Win32::Lanman::NetShareCheck("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "c:$\backslash{}$$\backslash{}$test", $\backslash{}$\$type)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$type; =item NetShareDel(\$server, \$path) Deletes share testshare on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetShareDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testshare")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetShareEnum(\$server, $\backslash{}$@shares) Enums all shares on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetShareEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@shares)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$share (@shares) \{ print "\$\{\$share\}\{'netname'\}$\backslash{}$n"; print "\$\{\$share\}\{'type'\}$\backslash{}$n"; print "\$\{\$share\}\{'remark'\}$\backslash{}$n"; print "\$\{\$share\}\{'permissions'\}$\backslash{}$n"; print "\$\{\$share\}\{'max\underscore{}uses'\}$\backslash{}$n"; print "\$\{\$share\}\{'current\underscore{}uses'\}$\backslash{}$n"; print "\$\{\$share\}\{'path'\}$\backslash{}$n"; print "\$\{\$share\}\{'passwd'\}$\backslash{}$n"; \#don't print these binary data \#print "\$\{\$share\}\{'security\underscore{}descriptor'\}$\backslash{}$n"; \} =item NetShareGetInfo(\$server, \$share, $\backslash{}$\%info) Gets information on share testshare on server $\backslash{}$$\backslash{}$testserver if(!Win32::Lanman::NetShareGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testshare", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$info\{'netname'\}$\backslash{}$n"; print "\$info\{'type'\}$\backslash{}$n"; print "\$info\{'remark'\}$\backslash{}$n"; print "\$info\{'permissions'\}$\backslash{}$n"; print "\$info\{'max\underscore{}uses'\}$\backslash{}$n"; print "\$info\{'current\underscore{}uses'\}$\backslash{}$n"; print "\$info\{'path'\}$\backslash{}$n"; print "\$info\{'passwd'\}$\backslash{}$n"; \#don't print these binary data \#print "\$info\{'security\underscore{}descriptor'\}$\backslash{}$n"; =item NetShareSetInfo(\$server, \$share, $\backslash{}$\%info) Sets information on share testshare on server $\backslash{}$$\backslash{}$testserver unless(Win32::Lanman::NetShareSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testshare", \{'remark' =$>$ 'new remark', 'max\underscore{}uses' =$>$ 5\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetConnectionEnum(\$server, \$share\underscore{}or\underscore{}computer, $\backslash{}$\%connections) Gets all connections made to the share testshare on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetConnectionEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testshare", $\backslash{}$\%conns)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em conn\/}(@conns) \{ foreach \$key(sort keys \%\$conn) \{ print "\$key=\$\{\$conn\}\{\$key\}$\backslash{}$n"; \} \} Gets all connections made from computer testcomputer to the server testserver. if(!Win32::Lanman::NetConnectionEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testcomputer", $\backslash{}$\%conns)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em conn\/}(@conns) \{ foreach \$key(sort keys \%\$conn) \{ print "\$key=\$\{\$conn\}\{\$key\}$\backslash{}$n"; \} \} =back =head2 Statistics =over 4 =item NetStatisticsGet(\$server, \$service, $\backslash{}$\%info) Retrieves operating statistics for a service. =back =head2 Statistics EXAMPLES: =over 4 Retrieves operating statistics for the service server on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetStatisticsGet("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "SERVER", $\backslash{}$\%statistics)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%statistics; foreach \$key (@keys) \{ print "\$key=\$statistics\{\$key\}$\backslash{}$n"; \} Retrieves operating statistics for the service workstation on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetStatisticsGet("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "WORKSTATION", $\backslash{}$\%statistics)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%statistics; foreach \$key (@keys) \{ print "\$key=\$statistics\{\$key\}$\backslash{}$n"; \} =back =head2 Workstation =over 4 =item NetWkstaGetInfo(\$server, $\backslash{}$@info, \$fullinfo) Returns information about the configuration elements for a workstation. =item NetWkstaSetInfo(\$server, $\backslash{}$\%info) Configures a workstation. =item NetWkstaTransportAdd(\$server, $\backslash{}$\%info) Binds (or connects) the redirector to the transport. =item NetWkstaTransportDel(\$server, \$transport, \$force) Unbinds the transport protocol from the redirector. =item NetWkstaTransportEnum(\$server, $\backslash{}$@info) Supplies information about transport protocols that are managed by the redirector. =item {\em NetWkstaUserGetInfo\/}($\backslash{}$@info) Returns information about the currently logged-on user. This function must be called in the context of the logged-on user. =item {\em NetWkstaUserSetInfo\/}($\backslash{}$@info) Returns information about the currently logged-on user. This function must be called in the context of the logged-on user. =item NetWkstaUserEnum(\$server, $\backslash{}$@info) Lists information about all users currently logged on to the workstation. =back =head2 Workstation EXAMPLES: =over 4 =item NetWkstaGetInfo(\$server, $\backslash{}$@info, \$fullinfo) Returns information about the configuration elements for $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaGetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \$key (@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetWkstaSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info) Configures $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaSetInfo(\$server, \{'char\underscore{}wait' =$>$ 3600, 'collection\underscore{}time' =$>$ 250, 'maximum\underscore{}collection\underscore{}count' =$>$ 16, 'keep\underscore{}conn' =$>$ 600, 'sess\underscore{}timeout' =$>$ 45, 'siz\underscore{}char\underscore{}buf' =$>$ 512\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetWkstaTransportAdd(\$server, $\backslash{}$\%info) Binds (or connects) the redirector to the transport on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaTransportAdd("$\backslash{}$$\backslash{}$testserver" \{'number\underscore{}of\underscore{}vcs' =$>$ 0, 'transport\underscore{}address' =$>$ '000000000000', 'transport\underscore{}name' =$>$ "$\backslash{}$$\backslash{}$Device$\backslash{}$$\backslash{}$NetBT\underscore{}NdisWan7", 'quality\underscore{}of\underscore{}service' =$>$ 0xffff\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetWkstaTransportDel(\$server, \$transport, \$force) Unbinds the transport protocol from the redirector on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaTransportDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "$\backslash{}$$\backslash{}$Device$\backslash{}$$\backslash{}$NetBT\underscore{}NdisWan7", USE\underscore{}FORCE)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetWkstaTransportEnum(\$server, $\backslash{}$@info) Supplies information about transport protocols that are managed by the redirector on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaTransportEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$transport (@info) \{ @keys = keys \%\$transport; foreach \$key (@keys) \{ print "\$key=\#\$\{\$transport\}\{\$key\}\#$\backslash{}$n"; \} \} =item {\em NetWkstaUserGetInfo\/}($\backslash{}$@info) Returns information about the currently logged-on user. This function must be called in the context of the logged-on user. {\em if\/}(!Win32::Lanman::NetWkstaUserGetInfo($\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \$key (@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item {\em NetWkstaUserSetInfo\/}($\backslash{}$@info) Returns information about the currently logged-on user. This function must be called in the context of the logged-on user. if(!Win32::Lanman::NetWkstaUserSetInfo(\{'username' =$>$ 'testuser', 'logon\underscore{}domain' =$>$ 'testdomain', 'oth\underscore{}domains' =$>$ 'test\underscore{}oth\underscore{}domain', 'logon\underscore{}server' =$>$ 'logonserver'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetWkstaUserEnum(\$server, $\backslash{}$@info) Lists information about all users currently logged on $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetWkstaUserEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$user (@info) \{ @keys = keys \%\$user; foreach \$key (@keys) \{ print "\$key=\#\$\{\$user\}\{\$key\}\#$\backslash{}$n"; \} \} =back =head2 Time and Misc =over 4 =item NetRemoteTOD(\$server, $\backslash{}$\%info) Returns the time of day information from a specified server. =item NetRemoteComputerSupports(\$server, \$options, $\backslash{}$\$supported) Retrieves the optional features the remote server supports. =back =head2 Time and Misc EXAMPLES: =over 4 =item NetRemoteTOD(\$server, $\backslash{}$\%info) Returns the time of day information from server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetRemoteTOD("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = keys \%info; foreach \${\em key\/}(@keys) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item NetRemoteComputerSupports(\$server, \$options, $\backslash{}$\$supported) Retrieves which of the options in \$options are supported on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetRemoteComputerSupports("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&SUPPORTS\underscore{}REMOTE\underscore{}ADMIN\underscore{}PROTOCOL $|$ \&SUPPORTS\underscore{}RPC $|$ \&SUPPORTS\underscore{}SAM\underscore{}PROTOCOL $|$ \&SUPPORTS\underscore{}UNICODE, $\backslash{}$\$supported)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "RAP is", (\$supported \& \&SUPPORTS\underscore{}REMOTE\underscore{}ADMIN\underscore{}PROTOCOL) ? "" : " not", " supported$\backslash{}$n"; print "RPC is", (\$supported \& \&SUPPORTS\underscore{}RPC) ? "" : " not", " supported$\backslash{}$n"; print "SAM is", (\$supported \& \&SUPPORTS\underscore{}SAM\underscore{}PROTOCOL) ? "" : " not", " supported$\backslash{}$n"; print "UNICODE is", (\$supported \& \&SUPPORTS\underscore{}UNICODE) ? "" : " not", " supported$\backslash{}$n"; =back =head2 Use =over 4 =item {\em NetUseAdd\/}($\backslash{}$\%info) Establishes a connection to a shared resource. =item NetUseDel(\$usename, {\tt [}\$forcedel{\tt ]}) Deletes a connection to a shared resource. =item {\em NetUseEnum\/}($\backslash{}$@info) Enumerates all connections to shared resources. =item NetUseGetInfo(\$usename, $\backslash{}$\%info) Gets information about a connection to a shared resource. =back =head2 Use EXAMPLES: =over 4 =item {\em NetUseAdd\/}($\backslash{}$\%info) Establishes a connection to a ipc\$ on server $\backslash{}$$\backslash{}$testserver. The connection will be established in context of user testdomain$\backslash{}$testuser. if(!Win32::Lanman::NetUseAdd(\{remote =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$ipc$\backslash{}$\$", password =$>$ "testpass", username =$>$ "testuser", domain =$>$ "testdomain", asg\underscore{}type =$>$ \&USE\underscore{}IPC\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} connects drive h: to $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. if(!Win32::Lanman::NetUseAdd(\{remote =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare", local =$>$ "h:", asg\underscore{}type =$>$ \&USE\underscore{}DISKDEV\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} connects port lpt3: to $\backslash{}$$\backslash{}$testserver$\backslash{}$testprint. if(!Win32::Lanman::NetUseAdd(\{remote =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testprint", local =$>$ "lpt3:", asg\underscore{}type =$>$ \&USE\underscore{}SPOOLDEV\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUseDel(\$usename, {\tt [}\$forcedel{\tt ]}) Deletes a connection to $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. If there are open files, the connection won't be closed. {\em if\/}(!Win32::Lanman::NetUseDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Deletes the connection to drive h:. If there are open files, the connection will be closed. if(!Win32::Lanman::NetUseDel("h:", \&USE\underscore{}FORCE)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item {\em NetUseEnum\/}($\backslash{}$@info) Enumerates all connections to shared resources. {\em if\/}(!Win32::Lanman::NetUseEnum($\backslash{}$@uses)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$use (@uses) \{ foreach (sort keys \%\$use) \{ print "\$\underscore{}=\$\{\$use\}\{\$\underscore{}\}$\backslash{}$n"; \} \} =item NetUseGetInfo(\$usename, $\backslash{}$\%info) Gets information about the to $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. if(!Win32::Lanman::NetUseGetInfo('$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare', $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach (sort keys \%info) \{ print "\$\underscore{}=\$info\{\$\underscore{}\}$\backslash{}$n"; \} =back =head2 User In this section, you cannot specify a domain name for the server parameter. Instead to affect domain accounts, obtain the PDC, using NetGetDCName, and then make the calls against this server. =over 4 =item NetUserAdd(\$server, $\backslash{}$\%user) Creates a new user \$user on server \$server. =item NetUserChangePassword(\$location, \$user, \$oldpassword, \$newpassword) Changes the password for user \$location$\backslash{}$\$user from \$oldpassword to \$newpassword. \$oldpassword must be supplied, otherwise you will get error 86 (wrong password). To Change the password for a domain account run the command on the PDC (not a BDC!). To change a user's password without knowing the old password use NetUserSetInfo or NetUserSetProp. To do this you need to have admin rights to perform the task. \$location should be either a domainname (clear text) or a servername ('$\backslash{}$$\backslash{}$server') for local machine accounts. Note in this function should you desire to create a local machine account you {\bf must} use the "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$my\underscore{}machine" format for \$location; the module does {\bf not} insert the '$\backslash{}$$\backslash{}$' for you for this function! =item NetUserCheckPassword(\$domain, \$user, \$password) Checks if a user password is valid or not. This function is implemented by the Win32 LogonUser function and tries to log on the user over the network. If the user account has been disabled, locked out or expired or the user has not been granted the SeNetworkLogonRight (access this computer from the network) privilege, the function fails even you have specified the correct password. With Windows 2000 your script needs the SeTcbPrivilege (act as part of the operating system) privilege. =item NetUserDel(\$server, \$user) Deletes user \$user on server \$server. =item NetUserEnum(\$domain, \$filter, $\backslash{}$@user) Enumerates all user in a domain or on a server. =item NetUserGetGroups(\$server, \$user, $\backslash{}$@groups) Enumerates all global groups on server \$server to which user \$user belongs. =item NetUserGetInfo(\$server, \$user, $\backslash{}$\%info) Retrieves information about user \$user on server \$server. =item NetUserGetLocalGroups(\$server, \$user, \$flags, $\backslash{}$@groups) Enumerates all local (and global if you specify LG\underscore{}INCLUDE\underscore{}INDIRECT in \$flags) groups on server \$server to which user \$user belongs. =item NetUserSetGroups(\$server, \$user, $\backslash{}$@groups) Sets global group memberships for user \$user on server \$server. =item NetUserSetInfo(\$server, \$user, $\backslash{}$\%info) Sets the parameters of user \$user on server \$server. You cannot specify a domain name, it must be a server. =item NetUserSetProp(\$server, \$user, $\backslash{}$\%info) Sets on or more parameters of user \$user on server \$server. You cannot specify a domain name, it must be a server. =item NetUserModalsGet(\$server, $\backslash{}$\%info) Retrieves global information for all users and global groups in the security database on server \$server. =item NetUserModalsSet(\$server, $\backslash{}$\%info) Sets global information for all users and global groups in the security database on server \$server. This call is not tested!!! =item StringToSid Converts a standard text format for a sid into the binary packed format used by NT internally =item SidToString Converts a sid in binary format to the standard text format ( e.g. S-1$-$3-3479834$-$3464-7664) =back =head2 User EXAMPLES: =over 4 =item NetUserAdd(\$server, $\backslash{}$@shares) Creates a new user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserAdd("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \{'name' =$>$ 'testuser', 'password' =$>$ 'testpassword', 'home\underscore{}dir' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare', 'comment' =$>$ 'test users comment', 'flags' =$>$ UF\underscore{}ACCOUNTDISABLE $|$ UF\underscore{}PASSWD\underscore{}CANT\underscore{}CHANGE $|$ UF\underscore{}TEMP\underscore{}DUPLICATE\underscore{}ACCOUNT, 'script\underscore{}path' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$logon\underscore{}script.bat', 'full\underscore{}name' =$>$ 'test users full name', 'usr\underscore{}comment' =$>$ 'test users usr comment', 'parms' =$>$ 'test users parameters', 'workstations' =$>$ 'comp0001,comp0002,comp0003,comp0004,comp0005,comp0006,comp0007,comp0008', 'profile' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$profile\underscore{}dir', 'home\underscore{}dir\underscore{}drive' =$>$ 'Y:', 'acct\underscore{}expires' =$>$ {\em time()\/} + 3600 $\ast$ 24, 'country\underscore{}code' =$>$ 49, 'code\underscore{}page' =$>$ 850, 'logon\underscore{}hours' =$>$ pack("b168", "000000001111111100000000" x 7), 'password\underscore{}expired' =$>$ 1\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserChangePassword(\$domain, \$user, \$oldpassword, \$newpassword) Changes user testuser's password in the domain testdomain. if(!Win32::Lanman::NetUserChangePassword("testdomain", 'testuser', 'old\underscore{}password', 'new\underscore{}password')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Changes user testuser's password on the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserChangePassword("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'testuser', 'old\underscore{}password', 'new\underscore{}password')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserCheckPassword(\$domain, \$user, \$password) Checks if user testuser's password testpass in the domain testdomain is valid or not. if(!Win32::Lanman::NetUserCheckPassword("testdomain", 'testuser', 'testpass')) \{ print "Password testpass for user testuser in domain testdomain isn't valid; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "Password testpass for user testuser in domain testdomain is valid."; Checks if user testuser's password testpass on the server $\backslash{}$$\backslash{}$testserver is valid or not. if(!Win32::Lanman::NetUserCheckPassword("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'testuser', 'testpass')) \{ print "Password testpass for user testuser on server $\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver isn't valid; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "Password testpass for user testuser on server $\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver is valid."; =item NetUserDel(\$server, \$user) Deletes user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserDel("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'testuser')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserEnum(\$domain, \$filter, $\backslash{}$@user) Enums all user in domain testdomain. All account types will be enumerated. if(!Win32::Lanman::NetUserEnum("testdomain", 0, $\backslash{}$@users)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$user (@users) \{ \$hours = unpack("b168", \$\{\$user\}\{'logon\underscore{}hours'\}); print "\$\{\$user\}\{'name'\}$\backslash{}$n"; print "\$\{\$user\}\{'comment'\}$\backslash{}$n"; print "\$\{\$user\}\{'usr\underscore{}comment'\}$\backslash{}$n"; print "\$\{\$user\}\{'full\underscore{}name'\}$\backslash{}$n"; print "\$\{\$user\}\{'password\underscore{}age'\}$\backslash{}$n"; print "\$\{\$user\}\{'priv'\}$\backslash{}$n"; print "\$\{\$user\}\{'home\underscore{}dir'\}$\backslash{}$n"; print "\$\{\$user\}\{'flags'\}$\backslash{}$n"; print "\$\{\$user\}\{'script\underscore{}path'\}$\backslash{}$n"; print "\$\{\$user\}\{'auth\underscore{}flags'\}$\backslash{}$n"; print "\$\{\$user\}\{'parms'\}$\backslash{}$n"; print "\$\{\$user\}\{'workstations'\}$\backslash{}$n"; print "\$\{\$user\}\{'last\underscore{}logon'\}$\backslash{}$n"; print "\$\{\$user\}\{'last\underscore{}logoff'\}$\backslash{}$n"; print "\$\{\$user\}\{'acct\underscore{}expires'\}$\backslash{}$n"; print "\$\{\$user\}\{'max\underscore{}storage'\}$\backslash{}$n"; print "\$\{\$user\}\{'units\underscore{}per\underscore{}week'\}$\backslash{}$n"; print "\$hours$\backslash{}$n"; print "\$\{\$user\}\{'bad\underscore{}pw\underscore{}count'\}$\backslash{}$n"; print "\$\{\$user\}\{'num\underscore{}logons'\}$\backslash{}$n"; print "\$\{\$user\}\{'logon\underscore{}server'\}$\backslash{}$n"; print "\$\{\$user\}\{'country\underscore{}code'\}$\backslash{}$n"; print "\$\{\$user\}\{'code\underscore{}page'\}$\backslash{}$n"; print "\$\{\$user\}\{'user\underscore{}id'\}$\backslash{}$n"; print "\$\{\$user\}\{'primary\underscore{}group\underscore{}id'\}$\backslash{}$n"; print "\$\{\$user\}\{'profile'\}$\backslash{}$n"; print "\$\{\$user\}\{'home\underscore{}dir\underscore{}drive'\}$\backslash{}$n"; print "\$\{\$user\}\{'password\underscore{}expired'\}$\backslash{}$n"; \} Enums all user on server $\backslash{}$$\backslash{}$testserver. Only normal accounts will be enumerated. if(!Win32::Lanman::NetUserEnum("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&FILTER\underscore{}NORMAL\underscore{}ACCOUNT, $\backslash{}$@users)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$user (@users) \{ \$hours = unpack("b168", \$\{\$user\}\{'logon\underscore{}hours'\}); print "\$\{\$user\}\{'name'\}$\backslash{}$n"; print "\$\{\$user\}\{'comment'\}$\backslash{}$n"; print "\$\{\$user\}\{'usr\underscore{}comment'\}$\backslash{}$n"; print "\$\{\$user\}\{'full\underscore{}name'\}$\backslash{}$n"; print "\$\{\$user\}\{'password\underscore{}age'\}$\backslash{}$n"; print "\$\{\$user\}\{'priv'\}$\backslash{}$n"; print "\$\{\$user\}\{'home\underscore{}dir'\}$\backslash{}$n"; print "\$\{\$user\}\{'flags'\}$\backslash{}$n"; print "\$\{\$user\}\{'script\underscore{}path'\}$\backslash{}$n"; print "\$\{\$user\}\{'auth\underscore{}flags'\}$\backslash{}$n"; print "\$\{\$user\}\{'parms'\}$\backslash{}$n"; print "\$\{\$user\}\{'workstations'\}$\backslash{}$n"; print "\$\{\$user\}\{'last\underscore{}logon'\}$\backslash{}$n"; print "\$\{\$user\}\{'last\underscore{}logoff'\}$\backslash{}$n"; print "\$\{\$user\}\{'acct\underscore{}expires'\}$\backslash{}$n"; print "\$\{\$user\}\{'max\underscore{}storage'\}$\backslash{}$n"; print "\$\{\$user\}\{'units\underscore{}per\underscore{}week'\}$\backslash{}$n"; print "\$hours$\backslash{}$n"; print "\$\{\$user\}\{'bad\underscore{}pw\underscore{}count'\}$\backslash{}$n"; print "\$\{\$user\}\{'num\underscore{}logons'\}$\backslash{}$n"; print "\$\{\$user\}\{'logon\underscore{}server'\}$\backslash{}$n"; print "\$\{\$user\}\{'country\underscore{}code'\}$\backslash{}$n"; print "\$\{\$user\}\{'code\underscore{}page'\}$\backslash{}$n"; print "\$\{\$user\}\{'user\underscore{}id'\}$\backslash{}$n"; print "\$\{\$user\}\{'primary\underscore{}group\underscore{}id'\}$\backslash{}$n"; print "\$\{\$user\}\{'profile'\}$\backslash{}$n"; print "\$\{\$user\}\{'home\underscore{}dir\underscore{}drive'\}$\backslash{}$n"; print "\$\{\$user\}\{'password\underscore{}expired'\}$\backslash{}$n"; \} =item NetUserGetGroups(\$server, \$user, $\backslash{}$@groups) Enums all global groups on server $\backslash{}$$\backslash{}$testserver to which user testuser belongs. if(!Win32::Lanman::NetUserGetGroups("testserver", "testuser", $\backslash{}$@groups)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$group (@groups) \{ print "\$\{\$group\}\{'name'\}$\backslash{}$n"; \} =item NetUserGetInfo(\$server, \$user, $\backslash{}$\%info) Retrieves information about user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserGetInfo("testserver", "testuser", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \$hours = unpack("b168", \$user\{'logon\underscore{}hours'\}); print "\$info\{'name'\}$\backslash{}$n"; print "\$info\{'comment'\}$\backslash{}$n"; print "\$info\{'usr\underscore{}comment'\}$\backslash{}$n"; print "\$info\{'full\underscore{}name'\}$\backslash{}$n"; print "\$info\{'password\underscore{}age'\}$\backslash{}$n"; print "\$info\{'priv'\}$\backslash{}$n"; print "\$info\{'home\underscore{}dir'\}$\backslash{}$n"; print "\$info\{'flags'\}$\backslash{}$n"; print "\$info\{'script\underscore{}path'\}$\backslash{}$n"; print "\$info\{'auth\underscore{}flags'\}$\backslash{}$n"; print "\$info\{'parms'\}$\backslash{}$n"; print "\$info\{'workstations'\}$\backslash{}$n"; print "\$info\{'last\underscore{}logon'\}$\backslash{}$n"; print "\$info\{'last\underscore{}logoff'\}$\backslash{}$n"; print "\$info\{'acct\underscore{}expires'\}$\backslash{}$n"; print "\$info\{'max\underscore{}storage'\}$\backslash{}$n"; print "\$info\{'units\underscore{}per\underscore{}week'\}$\backslash{}$n"; print "\$hours$\backslash{}$n"; print "\$info\{'bad\underscore{}pw\underscore{}count'\}$\backslash{}$n"; print "\$info\{'num\underscore{}logons'\}$\backslash{}$n"; print "\$info\{'logon\underscore{}server'\}$\backslash{}$n"; print "\$info\{'country\underscore{}code'\}$\backslash{}$n"; print "\$info\{'code\underscore{}page'\}$\backslash{}$n"; print "\$info\{'user\underscore{}id'\}$\backslash{}$n"; print "\$info\{'primary\underscore{}group\underscore{}id'\}$\backslash{}$n"; print "\$info\{'profile'\}$\backslash{}$n"; print "\$info\{'home\underscore{}dir\underscore{}drive'\}$\backslash{}$n"; print "\$info\{'password\underscore{}expired'\}$\backslash{}$n"; =item NetUserGetLocalGroups(\$server, \$user, \$flags, $\backslash{}$@groups) Enums all local and global groups on server $\backslash{}$$\backslash{}$testserver to which user testuser belongs. if(!Win32::Lanman::NetUserGetLocalGroups("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", \&LG\underscore{}INCLUDE\underscore{}INDIRECT, $\backslash{}$@groups)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$group (@groups) \{ print "\$\{\$group\}\{'name'\}$\backslash{}$n"; \} =item NetUserSetGroups(\$server, \$user, $\backslash{}$@groups) Sets global group memberships (domain users, testgroup1 and testgroup2) for user testuser on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserSetGroups("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", {\tt [}'domain users', 'testgroup1', 'testgroup2'{\tt ]})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserSetInfo(\$server, \$user, $\backslash{}$\%info) Sets the parameters of user testuser on server $\backslash{}$$\backslash{}$testserver. It's recommended that you first call NetUserGetInfo to retrieve the current user parameters. Than you'd change the desired parameters and call NetUserSetInfo to write the changed values back to the SAM. If you only want to change a few parameters, you'd use NetUSerSetProp. if(!Win32::Lanman::NetUserSetInfo("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", \{'name' =$>$ 'testuser', 'password' =$>$ 'testpassword', 'home\underscore{}dir' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare', 'comment' =$>$ 'test users comment', 'flags' =$>$ UF\underscore{}ACCOUNTDISABLE $|$ UF\underscore{}PASSWD\underscore{}CANT\underscore{}CHANGE $|$ UF\underscore{}TEMP\underscore{}DUPLICATE\underscore{}ACCOUNT, 'script\underscore{}path' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$logon\underscore{}script.bat', 'full\underscore{}name' =$>$ 'test users full name', 'usr\underscore{}comment' =$>$ 'test users usr comment', 'parms' =$>$ 'test users parameters', 'workstations' =$>$ 'comp0001,comp0002,comp0003,comp0004,comp0005,comp0006,comp0007,comp0008', 'profile' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$profile\underscore{}dir', 'home\underscore{}dir\underscore{}drive' =$>$ 'Y:', 'acct\underscore{}expires' =$>$ {\em time()\/} + 3600 $\ast$ 24, 'country\underscore{}code' =$>$ 49, 'code\underscore{}page' =$>$ 850, 'logon\underscore{}hours' =$>$ pack("b168", "000000001111111100000000" x 7), 'password\underscore{}expired' =$>$ 1\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserSetProp(\$server, \$user, $\backslash{}$\%info) Sets or or more the parameters of user testuser on server $\backslash{}$$\backslash{}$testserver. There's no need to call NetUserGetInfo first. You may specify the following parameters: name, password, home\underscore{}dir, comment, flags, script\underscore{}path, full\underscore{}name, usr\underscore{}comment, workstations, acct\underscore{}expires, logon\underscore{}hours, country\underscore{}code, code\underscore{}page, primary\underscore{}group\underscore{}id, profile and home\underscore{}dir\underscore{}drive. Because of the implementation, the call is not atomic. If a parameter couldn't be set, the call fails. if(!Win32::Lanman::NetUserSetProp("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", \{'name' =$>$ 'testuser', 'password' =$>$ 'testpassword', 'home\underscore{}dir' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare', 'comment' =$>$ 'test users comment', 'flags' =$>$ UF\underscore{}ACCOUNTDISABLE $|$ UF\underscore{}PASSWD\underscore{}CANT\underscore{}CHANGE $|$ UF\underscore{}TEMP\underscore{}DUPLICATE\underscore{}ACCOUNT, 'script\underscore{}path' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$logon\underscore{}script.bat', 'full\underscore{}name' =$>$ 'test users full name', 'usr\underscore{}comment' =$>$ 'test users usr comment', 'workstations' =$>$ 'comp0001,comp0002,comp0003,comp0004,comp0005,comp0006,comp0007,comp0008', 'acct\underscore{}expires' =$>$ {\em time()\/} + 3600 $\ast$ 24, 'logon\underscore{}hours' =$>$ pack("b168", "000000001111111100000000" x 7), 'country\underscore{}code' =$>$ 49, 'code\underscore{}page' =$>$ 850, 'primary\underscore{}group\underscore{}id' =$>$ 513, \# domain users 'profile' =$>$ '$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$profile\underscore{}dir', 'home\underscore{}dir\underscore{}drive' =$>$ 'Y:'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item NetUserModalsGet(\$server, $\backslash{}$\%info) Retrieves global information (account policies) for all users and global groups in the security database on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::NetUserModalsGet("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} @keys = {\em keys\/}(\%info); foreach \${\em key\/}(@keys) \{ print "\$key: \$info\{\$key\}$\backslash{}$n"; \} =item NetUserModalsSet(\$server, $\backslash{}$\%info) Sets global information (account policies) for all users and global groups in the security database on server $\backslash{}$$\backslash{}$testserver. Be really carefully in calling this. As a rule, first call NetUserModalsGet and then set the fields you want to modify. As last call NetUserModalsSet. You cannot change the domain id and the domain name. if(!Win32::Lanman::NetUserModalsGet("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Set minimum password age to 14 days, maximum password age to 2 months, minimum password length to 8 character \$info\{'min\underscore{}passwd\underscore{}age'\} = 14 $\ast$ 3600 $\ast$ 24; \$info\{'max\underscore{}passwd\underscore{}age'\} = 60 $\ast$ 3600 $\ast$ 24; \$info\{'min\underscore{}passwd\underscore{}len'\} = 8; if(!Win32::Lanman::NetUserModalsSet("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Windows Networking The Windows Networking functions offer a similar functionality like the NetUseXXX functions and some more. =over 4 =item {\em WNetAddConnection\/}($\backslash{}$\%useinfo) Connects a local device to a network resource. The function is implemented by the WNetAddConnection2 or the WNetAddConnection3 call. =item WNetCancelConnection(\$conn {\tt [}, \$flags {\tt [}, \$forcecancel{\tt ]} {\tt ]}) Cancels an existing network connection. The function is implemented by the WNetCancelConnection2 call. =item WNetEnumResource(\$scope, \$type, \$usage, $\backslash{}$\%startinfo, $\backslash{}$@resinfo) Enumerates network resources. =item WNetConnectionDialog({\tt [} $\backslash{}$\%info {\tt ]}) Shows a browsing dialog box for connecting to network resources. =item WNetDisconnectDialog({\tt [} $\backslash{}$\%info {\tt ]}) Shows a browsing dialog box for disconnecting from network resources. The function is implemented by the WNetDisconnectDialog or the WNetDisconnectDialog1 call. =item WNetGetConnection(\$local, $\backslash{}$\$remote) Retrieves the name of the network resource associated with a local device. =item WNetGetNetworkInformation(\$provider, $\backslash{}$\%info) Retrieves information about a network provider. =item WNetGetProviderName(\$type, $\backslash{}$\$provider) Obtains the provider name for a specific type of network. =item WNetGetResourceInformation($\backslash{}$\%resource, $\backslash{}$\%info) Obtains information about a network resource. =item WNetGetResourceParent($\backslash{}$\%resource, $\backslash{}$\%parent) Retrieves the parent of a network resource. =item WNetGetUniversalName(\$localname, $\backslash{}$\%info) Takes a drive based path for a network resource and returns information that contains a more universal form of the name. =item WNetGetUser(\$resource, $\backslash{}$\$user) Retrieves the current default user name, or the user name used to establish a network connection. =item WNetUseConnection($\backslash{}$\%resource {\tt [}, $\backslash{}$\%useinfo {\tt ]}) Makes a connection to a network resource. =back =head2 Windows Networking EXAMPLES: =over 4 =item {\em WNetAddConnection\/}($\backslash{}$\%useinfo) Connects the local device z: to the share testshare on server $\backslash{}$$\backslash{}$testserver. \$info\{type\} = \&RESOURCETYPE\underscore{}DISK; \$info\{localname\} = "z:"; \$info\{remotename\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare"; {\em if\/}(!Win32::Lanman::WNetAddConnection($\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Connects the local device x: to the share testshare on server $\backslash{}$$\backslash{}$testserver. The connection will be established with credentials from user testuser in the domain testdomain and the password testpass. The connection will be remembered if the user logs on again. \$info\{type\} = \&RESOURCETYPE\underscore{}DISK; \$info\{localname\} = "x:"; \$info\{remotename\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare"; \$info\{username\} = "testdomain$\backslash{}$$\backslash{}$testuser"; \$info\{password\} = "testpass"; \$info\{flags\} = \&CONNECT\underscore{}UPDATE\underscore{}PROFILE; You may also specify a network provider name. \$info\{provider\} = "Microsoft Windows Network"; {\em if\/}(!Win32::Lanman::WNetAddConnection($\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Connects the local device lpt1: to the printer testprinter on server $\backslash{}$$\backslash{}$testserver. \$info\{type\} = \&RESOURCETYPE\underscore{}PRINT; \$info\{localname\} = "lpt1:"; \$info\{remotename\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testprinter"; {\em if\/}(!Win32::Lanman::WNetAddConnection($\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Connects to ipc\$ on server $\backslash{}$$\backslash{}$testserver. The connection will be established with credentials from user testuser in the domain testdomain and the password testpass. \$info\{type\} = \&RESOURCETYPE\underscore{}ANY; \$info\{remotename\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testprinter"; \$info\{password\} = "testpass"; \$info\{flags\} = \&CONNECT\underscore{}UPDATE\underscore{}PROFILE; {\em if\/}(!Win32::Lanman::WNetAddConnection($\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WNetCancelConnection(\$conn {\tt [}, \$flags {\tt [}, \$forcecancel{\tt ]} {\tt ]}) Cancels the connection to drive z:. If there are open files to drive z: the connection won't be canceled. The connection to z: will be remembered if the user logs on again. {\em if\/}(!Win32::Lanman::WNetCancelConnection("z:")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Cancels the connection to drive z:. The connection will be canceled even if there are still open files. The connection to z: won't be remembered furthermore. if(!Win32::Lanman::WNetCancelConnection("z:", \&CONNECT\underscore{}UPDATE\underscore{}PROFILE, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Cancels the connection to $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. {\em if\/}(!Win32::Lanman::WNetCancelConnection("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Cancels the connection to printer port lpt1:. {\em if\/}(!Win32::Lanman::WNetCancelConnection("lpt1:")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WNetEnumResource(\$scope, \$type, \$usage, $\backslash{}$\%startinfo, $\backslash{}$@resinfo) Enumerates global resources in your network. if(!Win32::Lanman::WNetEnumResource(\&RESOURCE\underscore{}GLOBALNET, \&RESOURCETYPE\underscore{}ANY, 0, 0, $\backslash{}$@info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$item (@info) \{ foreach \$key (sort keys \%\$item) \{ print "\$key=\$\{\$item\}\{\$key\}$\backslash{}$n"; \} print "\#" x 80; \} Enumerates all resources in your network beginning at the top level. Be careful if you run this code in a bigger network. It may take a long time. sub EnumNetRes \{ my @info; my \$level = \$\underscore{}{\tt [}0{\tt ]}; return 0 unless Win32::Lanman::WNetEnumResource(\&RESOURCE\underscore{}GLOBALNET, \&RESOURCETYPE\underscore{}ANY, 0, \$\underscore{}{\tt [}1{\tt ]}, $\backslash{}$@info); foreach my \$item (@info) \{ print " " x (2 $\ast$ \$level), "provider=\#\$\{\$item\}\{provider\}\#$\backslash{}$n"; print " " x (2 $\ast$ \$level), "localname=\$\{\$item\}\{localname\}$\backslash{}$n"; print " " x (2 $\ast$ \$level), "remotename=\$\{\$item\}\{remotename\}$\backslash{}$n"; print " " x (2 $\ast$ \$level), "comment=\$\{\$item\}\{comment\}$\backslash{}$n"; print " " x (2 $\ast$ \$level), sprintf "scope=0x\%x$\backslash{}$n", \$\{\$item\}\{scope\}; print " " x (2 $\ast$ \$level), sprintf "type=0x\%x$\backslash{}$n", \$\{\$item\}\{type\}; print " " x (2 $\ast$ \$level), sprintf "usage=0x\%x$\backslash{}$n", \$\{\$item\}\{usage\}; print "\#" x 80; EnumNetRes(\$level + 1, \$item); \} \} {\em EnumNetRes()\/}; =item WNetConnectionDialog({\tt [} $\backslash{}$\%info {\tt ]}) Shows a browsing dialog box for connecting to network resources. print {\em Win32::Lanman::WNetConnectionDialog()\/} ? "Connection established" : "Dialog canceled"; Shows a browsing dialog box and specifies some flags. print Win32::Lanman::WNetConnectionDialog(\{flags =$>$ \&CONNDLG\underscore{}NOT\underscore{}PERSIST $|$ \&CONNDLG\underscore{}HIDE\underscore{}BOX\}) "Connection established" : "Dialog canceled"; Shows a browsing dialog box and specifies the server $\backslash{}$$\backslash{}$testserver and share testshare to connect. print Win32::Lanman::WNetConnectionDialog(\{flags =$>$ \&CONNDLG\underscore{}NOT\underscore{}PERSIST $|$ \&CONNDLG\underscore{}HIDE\underscore{}BOX, remotename =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare"\}) "Connection established" : "Dialog canceled"; =item WNetDisconnectDialog({\tt [} $\backslash{}$\%info {\tt ]}) Shows a browsing dialog box for disconnecting to network resources. print {\em Win32::Lanman::WNetDisconnectDialog()\/} ? "Connection removed" : "Dialog canceled"; Disconnects drive z: from the network resource. The disconnect is not forced and the connection to z: won't be remembered furthermore. if(!Win32::Lanman::WNetDisconnectDialog(\{localname =$>$ "z:", flags =$>$ \&DISC\underscore{}NO\underscore{}FORCE $|$ \&DISC\underscore{}UPDATE\underscore{}PROFILE\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "Connection removed"; =item WNetGetConnection(\$local, $\backslash{}$\$remote) Retrieves the name of the network resource associated with drive z:. if(!Win32::Lanman::WNetGetConnection("z:", $\backslash{}$\$remote)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "z:=\$remote"; Retrieves the name of the network resource associated with printer lpt1:. if(!Win32::Lanman::WNetGetConnection("lpt1:", $\backslash{}$\$remote)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "lpt1:=\$remote"; =item WNetGetNetworkInformation(\$provider, $\backslash{}$\%info) Retrieves information about the Microsoft Windows Network provider. if(!Win32::Lanman::WNetGetNetworkInformation("Microsoft Windows Network", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item WNetGetProviderName(\$type, $\backslash{}$\$provider) Obtains the provider name for the WNNC\underscore{}NET\underscore{}LANMAN network (Microsoft Windows Network). if(!Win32::Lanman::WNetGetProviderName(\&WNNC\underscore{}NET\underscore{}LANMAN, $\backslash{}$\$provider)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$provider; =item WNetGetResourceInformation($\backslash{}$\%resource, $\backslash{}$\%info) Obtains information about the file $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare$\backslash{}$testdir$\backslash{}$testfile.txt. The file must be exist. You may specify a network provider name, but it's optional. if(!Win32::Lanman::WNetGetResourceInformation(\{remotename =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare$\backslash{}$$\backslash{}$testdir$\backslash{}$$\backslash{}$testfile.txt", provider =$>$ "Microsoft Windows Network"\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item WNetGetResourceParent($\backslash{}$\%resource, $\backslash{}$\%parent) Retrieves the parent of the network resource $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. if(!Win32::Lanman::WNetGetResourceParent(\{remotename =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare", provider =$>$ "Microsoft Windows Network"\}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item WNetGetUniversalName(\$localname, $\backslash{}$\%info) Retrieves the universal form of the file name z:$\backslash{}$testdir$\backslash{}$testfile.txt. if(!Win32::Lanman::WNetGetUniversalName("z:$\backslash{}$$\backslash{}$testdir$\backslash{}$$\backslash{}$testfile.txt", $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key(sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item WNetGetUser(\$resource, $\backslash{}$\$user) Retrieves the user name used to establish a connection to drive z:. if(!Win32::Lanman::WNetGetUser("z:", $\backslash{}$\$user)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$user; =item WNetUseConnection($\backslash{}$\%resource {\tt [}, $\backslash{}$\%useinfo {\tt ]}) Connects drive z: to $\backslash{}$$\backslash{}$testserver$\backslash{}$testshare. If the current user has no access to the network resource, the system brings up a dialog to supply user credentials. if(!Win32::Lanman::WNetUseConnection(\{localname =$>$ "z:", remotename =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testshare", flags =$>$ \&CONNECT\underscore{}INTERACTIVE $|$ \&CONNECT\underscore{}PROMPT, type =$>$ \&RESOURCETYPE\underscore{}DISK\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Connects drive lpt1: to $\backslash{}$$\backslash{}$testserver$\backslash{}$testprinter. if(!Win32::Lanman::WNetUseConnection(\{localname =$>$ "lpt1:", remotename =$>$ "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testprinter", type =$>$ \&RESOURCETYPE\underscore{}PRINT\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head2 Services =over 4 Throughout these functions, which are used to manage services, you can specify the default service database by replacing \$servicedb with the empty string (or "ServicesActive"). Currently NT supports only the default database. If you specify an invalid database name, you'll get an error 1065 (database doesn't exist). =item StartService(\$server, \$servicedb, \$service) Starts the service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. =item StopService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Stops the service \$service on server \$server. The service status will be returned in \%status. Specify an empty string to use the default service database in \$servicedb. =item PauseService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Pauses the service \$service on server \$server. The service status will be returned in \%status. Specify an empty string to use the default service database in \$servicedb. =item ContinueService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Continues the service \$service on server \$server. The service status will be returned in \%status. Specify an empty string to use the default service database in \$servicedb. =item InterrogateService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Interrogates the service \$service on server \$server. The service status will be returned in \%status. Specify an empty string to use the default service database in \$servicedb. =item ControlService(\$server, \$servicedb, \$service, \$contol, $\backslash{}$\%status) Sends a control message to the service \$service on server \$server. The service status will be returned in \%status. Specify an empty string to use the default service database in \$servicedb. \$control can be one of the following commands: SERVICE\underscore{}CONTROL\underscore{}CONTINUE, SERVICE\underscore{}CONTROL\underscore{}INTERROGATE, SERVICE\underscore{}CONTROL\underscore{}PAUSE, SERVICE\underscore{}CONTROL\underscore{}STOP or a server specific control code between 128 and 255. Do not specify SERVICE\underscore{}CONTROL\underscore{}SHUTDOWN. To stop, continue, pause or interrogate a service, you can use the app. calls or ControlService. But you can send service specific controls between 128 and 255 to initiate a conversation with the service or something else. The most services ignore this messages. =item CreateService(\$server, \$servicedb, $\backslash{}$\%param) Creates a service on server \$server. Specify an empty string for the default service database in \$servicedb. Valid keys for \%param are: name : service name display : service display name in control panel applet type : service type SERVICE\underscore{}WIN32\underscore{}OWN\underscore{}PROCESS --- the service file contains only one service SERVICE\underscore{}WIN32\underscore{}SHARE\underscore{}PROCESS --- the service file contains more services SERVICE\underscore{}KERNEL\underscore{}DRIVER --- the service is a kernal driver SERVICE\underscore{}FILE\underscore{}SYSTEM\underscore{}DRIVER --- the service is a file system driver SERVICE\underscore{}INTERACTIVE\underscore{}PROCESS --- the service can interact with the desktop, must be or'ed with SERVICE\underscore{}WIN32\underscore{}OWN\underscore{}PROCESS or SERVICE\underscore{}WIN32\underscore{}SHARE\underscore{}PROCESS; if your service has to interact with the desktop, it has to run with the localsystem account start : when to start the service SERVICE\underscore{}BOOT\underscore{}START --- starts at boot time (device drivers) SERVICE\underscore{}SYSTEM\underscore{}START --- will be started by the IoInitSystem function (device drivers) SERVICE\underscore{}AUTO\underscore{}START --- will be started by the service control manager SERVICE\underscore{}DEMAND\underscore{}START --- will be started by calling StartService SERVICE\underscore{}DISABLED --- can't be started control : SERVICE\underscore{}ERROR\underscore{}IGNORE --- errors will be logged, startup will be continued SERVICE\underscore{}ERROR\underscore{}NORMAL --- errors will be logged, startup will be continued, message box will pop up SERVICE\underscore{}ERROR\underscore{}SEVERE --- errors will be logged, startup will be continued if the last known good configuration is started, otherwise the system is restarted with the last known good configuration SERVICE\underscore{}ERROR\underscore{}CRITICAL --- errors will be logged, startup failes if the last known good configuration is started, otherwise the system is restarted with the last known good configuration filename: path to the executable which runs for the service group : the load ordering group of which the service is a member tagid : unique identifier for the service in the load order group; only valid for device drivers dependencies array : the service will not start until all services or load ordering groups in the dependencies array are started account : account name for the service to log on as; Should be specified as one of 'domain$\backslash{}$username' for domain accounts or '.$\backslash{}$usr' or 'username' for machine accounts or 'LocalSystem' LocalSystem is not a real account, but instead species that the service will run with "the system account". Note if type includes SERVICE\underscore{}INTERACTIVE\underscore{}PROCESS then account must => 'LocalSystem'. The account chosen requires the logon as service privilege. password: password for account; if account =>LocalSystem, then password => '' =item DeleteService(\$server, \$servicedb, \$service) Deletes the service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. If you delete a running service, the service will be marked as deleted, but doesn't stop the service! To stop it, call StopService. =item EnumServicesStatus(\$server, \$servicedb, \$type, \$state, $\backslash{}$@services) Enums the status of all services on server \$server. Specify an empty string to use the default service database in \$servicedb. Valid types are: SERVICE\underscore{}WIN32 --- win32 services SERVICE\underscore{}DRIVER --- kernel driver Valid states are: SERVICE\underscore{}ACTIVE --- active services SERVICE\underscore{}INACTIVE --- inactive services SERVICE\underscore{}STATE\underscore{}ALL --- both of them =item EnumDependentServices(\$server, \$servicedb, \$service, \$state, $\backslash{}$@services) Enums all services dependent from service in \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. =item ChangeServiceConfig(\$server, \$servicedb, \$service, $\backslash{}$\%param) Changes the service configuration to the values specified in \%param for service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. For a description of \%param, see CreateService. =item GetServiceDisplayName(\$server, \$servicedb, \$service, $\backslash{}$\$display) Obtains the service display name of service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. =item GetServiceKeyName(\$server, \$servicedb, \$display, $\backslash{}$\$service) Obtains the service name from the service display name \$display on server \$server. Specify an empty string to use the default service database in \$servicedb. =item LockServiceDatabase(\$server, \$servicedb, $\backslash{}$\$lock) Locks the service control manager database on server \$server. Only one process can lock the database at a given time. LockServiceDatabase prevents the service control manager from starting services. You have to call UnlockServiceDatabase to unlock the database. Specify an empty string to use the default service database in \$servicedb. =item UnlockServiceDatabase(\$server, \$servicedb, \$lock) Unlocks the service control manager database on server \$server by releasing the lock \$lock. Specify an empty string to use the default service database in \$servicedb. =item QueryServiceLockStatus(\$server, \$servicedb, $\backslash{}$\%lock) Retrieves the lock status of the service control manager database on server \$server. Specify an empty string to use the default service database in \$servicedb. =item QueryServiceConfig(\$server, \$servicedb, \$service, $\backslash{}$\%config) Retrieves the configuration parameters of the service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. =item QueryServiceStatus(\$server, \$servicedb, \$service, $\backslash{}$\%status) Retrieves the current status of the service \$service on server \$server. Specify an empty string to use the default service database in \$servicedb. =item QueryServiceObjectSecurity(\$server, \$servicedb, \$service, \$securityinformation, $\backslash{}$\$securitydescriptor) Retrieves a security descriptor associated with the service \$service on server \$server. \$securityinformation specifies the requested security information. Valid security informations are OWNER\underscore{}SECURITY\underscore{}INFORMATION, GROUP\underscore{}SECURITY\underscore{}INFORMATION, DACL\underscore{}SECURITY\underscore{}INFORMATION and SACL\underscore{}SECURITY\underscore{}INFORMATION. To get SACL\underscore{}SECURITY\underscore{}INFORMATION, the calling process needs the SeSecurityPrivilege privilege enabled. Specify an empty string to use the default service database in \$servicedb. =item SetServiceObjectSecurity(\$server, \$servicedb, \$service, \$securityinformation, \$securitydescriptor) Sets a security descriptor of the service \$service on server \$server. \$securityinformation specifies the security information to set. Valid security informations are OWNER\underscore{}SECURITY\underscore{}INFORMATION, GROUP\underscore{}SECURITY\underscore{}INFORMATION, DACL\underscore{}SECURITY\underscore{}INFORMATION and SACL\underscore{}SECURITY\underscore{}INFORMATION. \$securitydescriptor must be a valid security descriptor. Note: Be careful when using this call, since if you revoke access to everyone, then nobody will be able to control the service. Also if you can grant the SERVICE\underscore{}START and SERVICE\underscore{}STOP rights to the everyone group, any people can start and stop your service (as default only administrators and power user can do this). Specify an empty string to use the default service database in \$servicedb. =item QueryServiceConfig2(\$server, \$servicedb, \$service, $\backslash{}$\%config) Retrieves the optional configuration parameters of the service \$service from the \$servicedb database. This function requires Windows 2000. =item ChangeServiceConfig2(\$server, \$servicedb, \$service, $\backslash{}$\%config) Changes the optional configuration parameters of the service \$service from the \$servicedb database. This function requires Windows 2000. =item QueryServiceStatusEx(\$server, \$servicedb, \$service, $\backslash{}$\%status) Retrieves the current status of the specified service. This function requires Windows 2000. =item EnumServicesStatusEx(\$server, \$servicedb, \$type, \$state, $\backslash{}$@services {\tt [}, \$group{\tt ]}) Enumerates services in the specified service control manager database. Filtering is done on type, state and group. The group parameter is optional. If you omit the group parameter, the function returns all services filtered only on type and state. This function requires Windows 2000. =back =head2 Services EXAMPLES: =over 4 =item StartService(\$server, \$servicedb, \$service) Starts the schedule service on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::StartService("testserver", '', "schedule")) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item StopService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Stops the schedule service on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::StopService("testserver", '', "schedule", $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$keyeach (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item PauseService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Pauses the schedule service on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::PauseService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', "schedule", $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$keyeach (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item ContinueService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Continues the schedule service on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::ContinueService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', "schedule", $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$keyeach (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item InterrogateService(\$server, \$servicedb, \$service, $\backslash{}$\%status) Interrogates the schedule service on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::InterrogateService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', "schedule", $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item ControlService(\$server, \$servicedb, \$service, \$contol, $\backslash{}$\%status) Stops the schedule service on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::ControlService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', "schedule", \&SERVICE\underscore{}CONTROL\underscore{}STOP, $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} Sends the value 130 to the service myservice on server $\backslash{}$$\backslash{}$testserver and prints the status flags. if(!Win32::Lanman::ControlService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', "myservice", 130, $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item CreateService(\$server, \$servicedb, $\backslash{}$\%param) Creates the service myservice on server $\backslash{}$$\backslash{}$testserver. The display name is 'my first service'. The service logs on with the testdomain$\backslash{}$testuser account. We have to grant the logon as service right. The service doesn't have dependencies. It will belong to the load ordering group 'myservices' if(!Win32::Lanman::GrantPrivilegeToAccount("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "SeServiceLogonRight", {\tt [}'testdomain$\backslash{}$$\backslash{}$testuser'{\tt ]}) $|$$|$ !Win32::Lanman::CreateService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', \{ name =$>$ 'myservice' display =$>$ 'my first service', type =$>$ \&SERVICE\underscore{}WIN32\underscore{}OWN\underscore{}PROCESS, start =$>$ \&SERVICE\underscore{}AUTO\underscore{}START, control =$>$ \&SERVICE\underscore{}ERROR\underscore{}NORMAL, filename =$>$ "C:$\backslash{}$$\backslash{}$WINNT$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$myservice.exe", group =$>$ 'myservices', account =$>$ 'testdomain$\backslash{}$$\backslash{}$testuser', password =$>$ 'testpass'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Creates the next service myservice2 on server $\backslash{}$$\backslash{}$testserver. The display name is 'my next service'. The service logs on with the LocalSystem account (this is because account and password are missing, so LocalSystem is the default). The service has no dependencies or load ordering group. The service can have more than one service in the same file and it can interact with the desktop. if(!Win32::Lanman::CreateService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', \{ name =$>$ 'myservice2' display =$>$ 'my next service', type =$>$ \&SERVICE\underscore{}WIN32\underscore{}SHARE\underscore{}PROCESS $|$ \&SERVICE\underscore{}INTERACTIVE\underscore{}PROCESS, start =$>$ \&SERVICE\underscore{}DEMAND\underscore{}START, control =$>$ \&SERVICE\underscore{}ERROR\underscore{}IGNORE, filename =$>$ "C:$\backslash{}$$\backslash{}$WINNT$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$mysrv\underscore{}x.exe"\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Creates the 3rd service myservice3 on server $\backslash{}$$\backslash{}$testserver. The display name is 'my 3rd service'. The service logs on with the LocalSystem account. The service doesn't have dependencies or a load ordering group. The service may have more than one service in the same file. if(!Win32::Lanman::CreateService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', \{ name =$>$ 'myservice3' display =$>$ 'my 3rd service', type =$>$ \&SERVICE\underscore{}WIN32\underscore{}SHARE\underscore{}PROCESS, start =$>$ \&SERVICE\underscore{}DEMAND\underscore{}START, control =$>$ \&SERVICE\underscore{}ERROR\underscore{}IGNORE, filename =$>$ "C:$\backslash{}$$\backslash{}$WINNT$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$mysrv\underscore{}x.exe", account =$>$ 'LocalSystem', password = ''\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Creates the 4th service myservice3 on server $\backslash{}$$\backslash{}$testserver. The display name is 'my 4th service'. The service logs on with the LocalSystem account. The service has dependencies (two services and one load ordering group). The service can interact with the desktop. if(!Win32::Lanman::CreateService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', \{ name =$>$ 'myservice4', display =$>$ 'my 4th service', type =$>$ \&SERVICE\underscore{}WIN32\underscore{}OWN\underscore{}PROCESS $|$ \&SERVICE\underscore{}INTERACTIVE\underscore{}PROCESS, start =$>$ \&SERVICE\underscore{}DEMAND\underscore{}START, control =$>$ \&SERVICE\underscore{}ERROR\underscore{}IGNORE, filename =$>$ "C:$\backslash{}$$\backslash{}$WINNT$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$mysrv4.exe", dependencies =$>$ {\tt [}'myservice2', 'myservice2', 'myservices'{\tt ]} \})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item DeleteService(\$server, \$servicedb, \$service) Deletes the service 'myservice' on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::DeleteService("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', 'myservice')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item EnumServicesStatus(\$server, \$servicedb, \$type, \$state, $\backslash{}$@services) Enums the status of all normal services on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumServicesStatus("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", \&SERVICE\underscore{}WIN32, \&SERVICE\underscore{}STATE\underscore{}ALL, $\backslash{}$@services)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$service (@services) \{ print "\$\{\$service\}\{name\}$\backslash{}$n"; foreach \$key (sort keys \%\$service) \{ print "$\backslash{}$t\$key = \$\{\$service\}\{\$key\}$\backslash{}$n" if \$key ne 'name'; \} \} Enums the status of all active kernel drivers on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumServicesStatus("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", \&SERVICE\underscore{}DRIVER, \&SERVICE\underscore{}ACTIVE, $\backslash{}$@services)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$service (@services) \{ print "\$\{\$service\}\{name\}$\backslash{}$n"; foreach \$key (sort keys \%\$service) \{ print "$\backslash{}$t\$key = \$\{\$service\}\{\$key\}$\backslash{}$n" if \$key ne 'name'; \} \} =item EnumDependentServices(\$server, \$servicedb, \$service, \$state, $\backslash{}$@services) Enums the name and status of all services depend on service LanmanWorkstation on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumDependentServices("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'LanmanWorkstation', \&SERVICE\underscore{}STATE\underscore{}ALL, $\backslash{}$@services)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$service (@services) \{ print "\$\{\$service\}\{name\}$\backslash{}$n"; foreach \$key (sort keys \%\$service) \{ print "$\backslash{}$t\$key = \$\{\$service\}\{\$key\}$\backslash{}$n" if \$key ne 'name'; \} \} =item ChangeServiceConfig(\$server, \$servicedb, \$service, $\backslash{}$\%param) Changes the service configuration for service myservice on server $\backslash{}$$\backslash{}$testserver. You have to specify only the properties you want to change. All the others remain their values. In this example, we only change the display and account information. Don't forget to grant the logon as service right to testdomain$\backslash{}$testuser. See also CreateService examples. if(!Win32::Lanman::ChangeServiceConfig("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', \{ name =$>$ 'myservice' display =$>$ 'a new display name', account =$>$ 'testdomain$\backslash{}$$\backslash{}$testuser', password =$>$ 'testpass'\})) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item GetServiceDisplayName(\$server, \$servicedb, \$service, $\backslash{}$\$display) Obtains the service display name of service myservice on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::GetServiceDisplayName("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'myservice', $\backslash{}$\$display)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$display; =item GetServiceKeyName(\$server, \$servicedb, \$display, $\backslash{}$\$service) Obtains the service name from the service display name 'my newest service' on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::GetServiceKeyName("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'my newest service', $\backslash{}$\$service)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$service; =item LockServiceDatabase(\$server, \$servicedb, $\backslash{}$\$lock) Locks the service control manager database on server $\backslash{}$$\backslash{}$testserver. If locked, do any stuff and the unlock the database. if(!Win32::Lanman::LockServiceDatabase("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", $\backslash{}$\$lock)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \# do any stuff here... if(!Win32::Lanman::UnlockServiceDatabase("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", \$lock)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item UnlockServiceDatabase(\$server, \$servicedb, \$lock) Unlocks the service control manager database on server $\backslash{}$$\backslash{}$testserver. See the example above. =item QueryServiceLockStatus(\$server, \$servicedb, $\backslash{}$\%lock) Retrieves the lock status of the service control manager database on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::QueryServiceLockStatus("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", $\backslash{}$\%lock)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$key (sort keys \%lock) \{ print "\$key = \$lock\{\$key\}$\backslash{}$n"; \} =item QueryServiceConfig(\$server, \$servicedb, \$service, $\backslash{}$\%config) Retrieves the configuration parameters of the service myservice on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::QueryServiceConfig("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", '', 'myservice', $\backslash{}$\%config)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$key (sort keys \%config) \{ if(\$key eq "dependencies") \{ \$dependencies = \$config\{\$key\}; print "$\backslash{}$t\$key = ", \$\#\$dependencies + 1, "$\backslash{}$n"; foreach \$dependency (@\$dependencies) \{ print "$\backslash{}$t$\backslash{}$t\$dependency$\backslash{}$n"; \} \} else \{ print "$\backslash{}$t\$key = \$config\{\$key\}$\backslash{}$n"; \} \} =item QueryServiceStatus(\$server, \$servicedb, \$service, $\backslash{}$\%status) Retrieves the current status of the service myservice on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::QueryServiceStatus("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'myservice', $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} for \$key (sort keys \%status) \{ print "\$key = \$status\{\$key\}$\backslash{}$n"; \} =item QueryServiceObjectSecurity(\$server, \$servicedb, \$service, \$securityinformation, $\backslash{}$\$securitydescriptor) Retrieves a security descriptor associated with the service \$service on server \$server. OWNER\underscore{}SECURITY\underscore{}INFORMATION, GROUP\underscore{}SECURITY\underscore{}INFORMATION, DACL\underscore{}SECURITY\underscore{}INFORMATION and SACL\underscore{}SECURITY\underscore{}INFORMATION will be retrieved. \$securityinformation = \&OWNER\underscore{}SECURITY\underscore{}INFORMATION $|$ \&GROUP\underscore{}SECURITY\underscore{}INFORMATION $|$ \&DACL\underscore{}SECURITY\underscore{}INFORMATION $|$ \&SACL\underscore{}SECURITY\underscore{}INFORMATION; if(!Win32::Lanman::QueryServiceObjectSecurity("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'myservice', \$securityinformation, $\backslash{}$\$securitydescriptor)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \#Do not print these binary data. \#print \$securitydescriptor; =item SetServiceObjectSecurity(\$server, \$servicedb, \$service, \$securityinformation, \$securitydescriptor) Sets a security descriptor of the service myservice on server $\backslash{}$$\backslash{}$testserver. Only DACL\underscore{}SECURITY\underscore{}INFORMATION will be set. You have to build a valid security descriptor in \$securitydescriptor. \#build a valid security descriptor \#\$securitydescriptor = ... if(!Win32::Lanman::SetServiceObjectSecurity("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'myservice', \&DACL\underscore{}SECURITY\underscore{}INFORMATION, \$securitydescriptor)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item QueryServiceConfig2(\$server, \$servicedb, \$service, $\backslash{}$\%config) Retrieves the optional configuration parameters of the service testserv on the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::QueryServiceConfig2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'testserv', $\backslash{}$\%config)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%config) \{ print "\$key = \$config\{\$key\}$\backslash{}$n"; \} =item ChangeServiceConfig2(\$server, \$servicedb, \$service, $\backslash{}$\%config) Changes the optional configuration parameters of the service testserv on server $\backslash{}$$\backslash{}$testserver. Unfortunately, you cannot configure the actions parameters. I don't know why, but the call fails as soon as the actions parameter is specified. \$config\{description\} = 'This is a service description'; \$config\{command\} = 'c:$\backslash{}$$\backslash{}$winnt$\backslash{}$$\backslash{}$system32$\backslash{}$$\backslash{}$notepad.exe'; \$config\{rebootmsg\} = 'This is a reboot message'; \$config\{resetperiod\} = 100; \#@actions = (\{type =$>$ \&SC\underscore{}ACTION\underscore{}NONE, delay =$>$ 1000\}, \# \{type =$>$ \&SC\underscore{}ACTION\underscore{}REBOOT, delay =$>$ 2000\}, \# \{type =$>$ \&SC\underscore{}ACTION\underscore{}RESTART, delay =$>$ 3000\}, \# \{type =$>$ \&SC\underscore{}ACTION\underscore{}RUN\underscore{}COMMAND, delay =$>$ 4000\}); \#\$config\{actions\} = $\backslash{}$@actions; if(!Win32::Lanman::ChangeServiceConfig2("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'testserv', $\backslash{}$\%config)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item QueryServiceStatusEx(\$server, \$servicedb, \$service, $\backslash{}$\%status) Retrieves the current status of the service testserv on the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::QueryServiceStatusEx("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", 'testserv', $\backslash{}$\%status)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%status) \{ print "$\backslash{}$t\$key = \$status\{\$key\}$\backslash{}$n"; \} =item EnumServicesStatusEx(\$server, \$servicedb, \$type, \$state, $\backslash{}$@services {\tt [}, \$group{\tt ]}) Enumerates all services belonging to the group testgroup on the server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::EnumServicesStatusEx("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "", \&SERVICE\underscore{}WIN32 $|$ \&SERVICE\underscore{}DRIVER, \&SERVICE\underscore{}STATE\underscore{}ALL, $\backslash{}$\%services, 'testgroup')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$service (@services) \{ foreach \$key (sort keys \%\$service) \{ print "$\backslash{}$t\$key = \$\{\$service\}\{\$key\}$\backslash{}$n"; \} \} =back =head2 Eventlog =over 4 Throughout this section \$source will represent the event log source, which can only be "application" or "system" or "security". =item ReadEventLog(\$server, \$source, \$first, \$last, $\backslash{}$@events) Reads events in the range from \$first to \$last from the event log \$source on server \$server in the order \$first to \$last. So y ou can read forward ,when \$first <= \$last, or backward , by having \$first > \$last. Sequential reads as with NT EventViewer's Next and Previous buttons, are not supported. This is because after each call the event log is closed. To get all events set \$first to 1 and \$last to $-$1 (or 0xffffffff if you prefer). =item GetEventDescription(\$server, $\backslash{}$\%event) Retrieves the description of the event \%event on server \$server. \%event must be retrieved by a ReadEventLog call. =item ClearEventLog(\$server, \$source {\tt [}, \$filename{\tt ]}) Clears the eventlog \$source on server \$server and makes an optionally backup to file \$filename before clearing. ClearEventLog will fail with error 183 (couldn't create existing file). In this case, the eventlog will not be cleared. =item BackupEventLog(\$server, \$source, \$filename) Makes a backup from the eventlog \$source on server \$server to file \$filename. As with ClearEventLog, BackupEventLog fails if filename exists. =item ReportEvent(\$server, \$source, \$type, \$category, \$id, \$sid, $\backslash{}$@strings, \$data) Writes an event to the event log \$source on server \$server. =item GetNumberOfEventLogRecords(\$server, \$source, $\backslash{}$\$numrecords) Retrieves the number of records in the event log \$source on server \$server. =item GetOldestEventLogRecord(\$server, \$source, $\backslash{}$\$oldestrecord) Retrieves the oldest record number in the event log \$source on server \$server. =back =head2 Eventlog EXAMPLES: =over 4 =item ReadEventLog(\$server, \$source, \$first, \$last, $\backslash{}$@events) Reads all events from the system event log in the range from the first to the last event on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::ReadEventLog("testserver", 'system', 0, 0xffffffff, $\backslash{}$@events)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Reads all events from the security event log in reverse order on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::ReadEventLog("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'security', 0xffffffff, 0, $\backslash{}$@events)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Retrieves the first and the last record number in the application log on server $\backslash{}$$\backslash{}$testserver. Then it reads all these events and prints out the event properties. if(!Win32::Lanman::GetOldestEventLogRecord("testserver", 'application', $\backslash{}$\$first)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::GetNumberOfEventLogRecords("testserver", 'application', $\backslash{}$\$last)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \$last += \$first --- 1; if(!Win32::Lanman::ReadEventLog("testserver", 'application', \$first, \$last, $\backslash{}$@events)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em event\/}(@events) \{ \#get the event description for the event \$\{\$event\}\{'eventdescription'\} = "$\ast$$\ast$$\ast$ Error get event description $\ast$$\ast$$\ast$" if !Win32::Lanman::GetEventDescription("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$event); \$\{\$event\}\{'eventdescription'\} = join('', split(/$\backslash{}$r/, \$\{\$event\}\{'eventdescription'\})); \$\{\$event\}\{'eventdescription'\} = join('', split(/$\backslash{}$n/, \$\{\$event\}\{'eventdescription'\})); print '\#' x 80; @keys = sort keys \%\$event; foreach \${\em key\/}(@keys) \{ if(\$key eq 'strings') \{ \$strings = \$\{\$event\}\{\$key\}; print "strings$\backslash{}$n"; foreach \${\em string\/}(@\$strings) \{ print "$\backslash{}$t\$string$\backslash{}$n"; \} \} elsif(\$key eq 'eventid') \{ \#this is the event id you'll see in event viewer; the highest 16 bit are discarded print "\$key=" . (\$\{\$event\}\{\$key\} \& 0xffff) . "$\backslash{}$n"; \#this is the real event id \#print "\$key=" . (\$\{\$event\}\{\$key\}) . "$\backslash{}$n"; \} elsif(\$key eq 'timegenerated' $|$$|$ \$key eq 'timewritten') \{ print "\$key=" . {\em localtime\/}(\$\{\$event\}\{\$key\}) . "$\backslash{}$n"; \} elsif(\$key eq 'usersid' $|$$|$ \$key eq 'data') \{ print "\$key=" . unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$event\}\{\$key\}), \$\{\$event\}\{\$key\}) . "$\backslash{}$n"; \} else \{ print "\$key=\$\{\$event\}\{\$key\}$\backslash{}$n"; \} \} \} =item GetEventDescription(\$server, $\backslash{}$\%event) Retrieves all records in the system log on server $\backslash{}$$\backslash{}$testserver. Then it reads all these events and prints out the event descriptions. if(!Win32::Lanman::ReadEventLog("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'system', 0, $-$1, $\backslash{}$@events)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em event\/}(@events) \{ \#get the event description for the event \$\{\$event\}\{'eventdescription'\} = "$\ast$$\ast$$\ast$ Error get event description $\ast$$\ast$$\ast$" if !Win32::Lanman::GetEventDescription("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$event); print \$\{\$event\}\{'eventdescription'\}; \} =item BackupEventLog(\$server, \$source, \$filename) Makes a backup from the application eventlog on server $\backslash{}$$\backslash{}$testserver to the file application.evt. if(!Win32::Lanman::BackupEventLog("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'application', 'application.evt')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item ClearEventLog(\$server, \$source {\tt [}, \$filename{\tt ]}) Makes a backup from the application eventlog on server $\backslash{}$$\backslash{}$testserver to the file application.evt. Thereafter the application event log will be cleared. if(!Win32::Lanman::ClearEventLog("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'application', 'application.evt')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} Clears the system eventlog on server $\backslash{}$$\backslash{}$testserver without backing up the events. if(!Win32::Lanman::ClearEventLog("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'system')) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item ReportEvent(\$server, \$source, \$type, \$category, \$id, \$sid, $\backslash{}$@strings, \$data) Reports an event to the event log on server $\backslash{}$$\backslash{}$testserver. \#build administrators sid \$sid = pack("C16", 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0 , 0); unless(Win32::Lanman::ReportEvent("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'Print', \&EVENTLOG\underscore{}ERROR\underscore{}TYPE, 100, 256, \$sid, {\tt [}'string1', 'string2', 'string3'{\tt ]}, 'Here is my data ...') ) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item GetNumberOfEventLogRecords(\$server, \$source, $\backslash{}$\$numrecords) Retrieves the number of records in the event log system on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::GetNumberOfEventLogRecords("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'system', $\backslash{}$\$numrecords)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$numrecords$\backslash{}$n"; =item GetOldestEventLogRecord(\$server, \$source, $\backslash{}$\$oldestrecord) Retrieves the oldest record number in the event log system on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::GetOldestEventLogRecord("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 'system', $\backslash{}$\$oldestrecord)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print "\$oldestrecord$\backslash{}$n"; =back =head2 Windows Terminal Server (WTS) =over 4 =item Note: The WTS dll (wtsapi32.dll) is not an integral part of Windows NT. The Lanman module tries to loads the dll dynamically when your script starts. The dll is not statically linked. If the dll is present and can be loaded, then you can call the WTS functions. But if the dll cannot be loaded, every WTS call fails. {\em GetLastError()\/} returns 126 (ERROR\underscore{}MOD\underscore{}NOT\underscore{}FOUND). Wtsapi32.dll needs three additional dlls: utildll.dll, regapi.dll and winsta.dll. Copy each of these dlls into your system32 directory. =item WTSEnumerateServers(\$domain, $\backslash{}$@sessions) Enumerates all WTS server in domain. =item WTSOpenServer(\$server, $\backslash{}$\$handle) Opens an handle on a WTS server. This call is not really necessary and only implemented for completeness and for those keenly interested in performance. With the WTS api you have to open a server handle, then call your WTS function and close the handle with WTSCloseServer at the end. The module opens the handle every time you call a WTS function, makes the job and closes the handle at the end. The advantage: you don't need to deal with handles, the downside: the overhead in opening and closing a handle at each call. =item {\em WTSCloseServer\/}(\$handle) Closes an handle on a WTS server. This call is not really necessary and only implemented for completeness. See also the remarks at WTSOpenServer. =item WTSEnumerateSessions(\$server, $\backslash{}$@sessions) Enumerates sessions on a WTS server. =item WTSEnumerateProcesses(\$server, $\backslash{}$@processes) Enumerates processes on a WTS server. =item WTSTerminateProcess(\$server, \$processid {\tt [}, \$exitcode{\tt ]}) Terminates a process on a WTS server. =item WTSQuerySessionInformation(\$server, \$sessionid, $\backslash{}$@infoclass, $\backslash{}$\%info) Returns information about the specified session on a WTS server. You need to specify which information you are interested in. To get all information available, use {\em WTSInfoClassAll()\/} as @infoclass parameter. =item WTSQueryUserConfig(\$server, \$user, $\backslash{}$@infoclass, $\backslash{}$\%config) Returns the WTS user properties. Call this on your domains primary domain controller. You need to specify which information you are interested in. To get all information available, use {\em WTSUserConfigAll()\/} as @infoclass parameter. =item WTSSetUserConfig(\$server, \$user, $\backslash{}$\%config) Sets the WTS user properties. Call this on your primary domain controller. The function sets all information contained in the \%config hash. =item WTSSendMessage(\$server, \$sessionid, \$title, \$message{\tt [}, \$style {\tt [}, \$timeout {\tt [}, $\backslash{}$\$response{\tt ]}{\tt ]}{\tt ]}) Displays a message box on the client desktop of a WTS session. =item WTSDisconnectSession(\$server, \$sessionid {\tt [}, \$wait{\tt ]}) Disconnects the logged on user from the specified WTS session without closing the session. =item WTSLogoffSession(\$server, \$sessionid {\tt [}, \$wait{\tt ]}) Logs off the specified WTS session. =item WTSShutdownSystem(\$server{\tt [}, \$flag{\tt ]}) Shuts down the specified WTS server. Avoid this call. I believe it doesn't behave as expected. It ignores the \$server parameter and shuts down the local machine. Is this a bug or a feature? I don't know. =item WTSWaitSystemEvent(\$server{\tt [}, \$flag{\tt ]}) Waits for a WTS event before returning to the caller. =back =head2 Windows Terminal Server (WTS) EXAMPLES: =over 4 =item WTSEnumerateServers(\$domain, $\backslash{}$@sessions) Enumerates all WTS server in domain testdomain. if(!Win32::Lanman::WTSEnumerateServers("testdomain", $\backslash{}$@servers)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \${\em server\/}(@servers) \{ print "\$\{\$server\}\{name\}$\backslash{}$n"; \} =item WTSOpenServer(\$server, $\backslash{}$\$handle) Opens and closes a WTS handle on server $\backslash{}$$\backslash{}$testserver. These calls are not really necessary. See the description above. if(!Win32::Lanman::WTSOpenServer("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \# use the handle \# ... {\em if\/}(!Win32::Lanman::WTSCloseServer(\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item {\em WTSCloseServer\/}(\$handle) Opens and closes a WTS handle on server $\backslash{}$$\backslash{}$testserver. These calls are not really necessary. See the description above. if(!Win32::Lanman::WTSOpenServer("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} \# use the handle \# ... {\em if\/}(!Win32::Lanman::WTSCloseServer(\$handle)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WTSEnumerateSessions(\$server, $\backslash{}$@sessions) Enumerates all sessions on the WTS server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::WTSEnumerateSessions("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@sessions)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$session (@sessions) \{ foreach \$key (keys \%\$session) \{ print "\$key=\$\{\$session\}\{\$key\}$\backslash{}$n"; \} \} =item WTSEnumerateProcesses(\$server, $\backslash{}$@processes) Enumerates all processes on the WTS server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::WTSEnumerateProcesses("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@processes)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$process (@processes) \{ foreach \$key (keys \%\$process) \{ if(\$key eq "sid") \{ print "\$key=", unpack("H" . 2 $\ast$ {\em length\/}(\$\{\$process\}\{\$key\}), \$\{\$process\}\{\$key\}), "$\backslash{}$n"; \} else \{ print "\$key=\$\{\$process\}\{\$key\}$\backslash{}$n"; \} \} \} =item WTSTerminateProcess(\$server, \$processid {\tt [}, \$exitcode{\tt ]}) Terminates all processes which belongs to disconnected sessions on the WTS server $\backslash{}$$\backslash{}$testserver (these have windowstation parameter of the empty string). All processes terminate with the exit value 3 (if you omit the exitcode, the processes terminate with exit code 0). You'll get some access denied errors (error 5) because you cannot terminate system processes like csrss or winlogon. if(!Win32::Lanman::WTSEnumerateSessions("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@sessions)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} if(!Win32::Lanman::WTSEnumerateProcesses("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", $\backslash{}$@processes)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$session (@sessions) \{ next if \$\{\$session\}\{winstationname\} ne ""; foreach \$process (@processes) \{ next unless \$\{\$process\}\{sessionid\} == \$\{\$session\}\{id\}; print "\$\{\$process\}\{name\} (\$\{\$process\}\{processid\}) will be terminated$\backslash{}$n"; if(!Win32::Lanman::WTSTerminateProcess("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \$\{\$process\}\{processid\}, 3)) \{ print "Oops, cannot terminate process \$\{\$process\}\{processid\}; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; print "$\backslash{}$n"; \} \} \} =item WTSQuerySessionInformation(\$server, \$sessionid, $\backslash{}$@infoclass, $\backslash{}$\%info) Returns all information available for the session id 0 (session 0 is the WTS console) on server $\backslash{}$$\backslash{}$testserver. if(!Win32::Lanman::WTSQuerySessionInformation("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 0, {\tt [}{\em WTSInfoClassAll()\/}{\tt ]}, $\backslash{}$\%info)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%info) \{ print "\$key=\$info\{\$key\}$\backslash{}$n"; \} =item WTSQueryUserConfig(\$server, \$user, $\backslash{}$@infoclass, $\backslash{}$\%config) Returns all WTS specific user properties for user testuser from server $\backslash{}$$\backslash{}$testserver. $\backslash{}$$\backslash{}$testserver should be your primary domain controller. if(!Win32::Lanman::WTSQueryUserConfig("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", {\tt [}{\em WTSUserConfigAll()\/}{\tt ]}, $\backslash{}$\%user)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} foreach \$key (sort keys \%user) \{ print "\$key=\$user\{\$key\}$\backslash{}$n"; \} =item WTSSetUserConfig(\$server, \$user, $\backslash{}$\%config) Set WTS specific user properties for user testuser from server $\backslash{}$$\backslash{}$testserver. $\backslash{}$$\backslash{}$testserver should be your primary domain controller. In this sample the WTS profile path will be set to $\backslash{}$$\backslash{}$testserver$\backslash{}$testpath$\backslash{}$profile and the working directory to c:$\backslash{}$work$\backslash{}$testuser. \$user\{terminalserverprofilepath\} = "$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver$\backslash{}$$\backslash{}$testpath$\backslash{}$$\backslash{}$profile"; \$user\{workingdirectory\} = "c:$\backslash{}$$\backslash{}$work$\backslash{}$$\backslash{}$testuser"; if(!Win32::Lanman::WTSSetUserConfig("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", "testuser", $\backslash{}$\%user)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WTSSendMessage(\$server, \$sessionid, \$title, \$message{\tt [}, \$style {\tt [}, \$timeout {\tt [}, $\backslash{}$\$response{\tt ]}{\tt ]}{\tt ]}) Displays a message box with the text "a message to the console" and the caption "hi console user" on the console desktop (session id 0) on the WTS $\backslash{}$$\backslash{}$testserver. The message box disappears after 15 seconds or if the user presses the Ok button. You can specify a style or 0 for the default (simply an Ok button). The available style values you'll find in the MessageBox description in the platform sdk. If you pass a response value, the call returns which button the user pressed or if the timeout elapsed. If you omit the timeout value or the timeout is null, the function returns immediately. Otherwise it returns if the user pressed a button on the message box or if the timeout elapsed. if(!Win32::Lanman::WTSSendMessage("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 0, "a message to the console", "hi console user", 0, 15, $\backslash{}$\$response)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} print \$response; =item WTSDisconnectSession(\$server, \$sessionid {\tt [}, \$wait{\tt ]}) Disconnects the user logged on the desktop window station (session id 0) on server $\backslash{}$$\backslash{}$testserver. The session is closed only. The user won't be logged off. The calling process waits til the connection is closed (\$wait == 1). if(!Win32::Lanman::WTSDisconnectSession("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 0, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WTSLogoffSession(\$server, \$sessionid {\tt [}, \$wait{\tt ]}) Logs off the user logged on the desktop window station (session id 0) on server $\backslash{}$$\backslash{}$testserver. The calling process waits until the user is logged off (\$wait == 1). if(!Win32::Lanman::WTSDisconnectSession("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", 0, 1)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =item WTSShutdownSystem(\$server{\tt [}, \$flag{\tt ]}) Avoid using this call. It's buggy. See the notes above. =item WTSWaitSystemEvent(\$server{\tt [}, \$flag{\tt ]}) Waits for the WTS event WTS\underscore{}EVENT\underscore{}LOGON (a user logs on) on server $\backslash{}$$\backslash{}$testserver and returns as soon as the event occurs. You'll find the available events in the constants section above (WTS\underscore{}EVENT\underscore{}$\ast$). You can specify more than one event type by or'ing them. The \$event returns which event occured. if(!Win32::Lanman::WTSWaitSystemEvent("$\backslash{}$$\backslash{}$$\backslash{}$$\backslash{}$testserver", \&WTS\underscore{}EVENT\underscore{}LOGON $|$ \&WTS\underscore{}EVENT\underscore{}LOGOFF, $\backslash{}$\$event)) \{ print "Sorry, something went wrong; error: "; \# get the error code print {\em Win32::Lanman::GetLastError()\/}; exit 1; \} =back =head1 AUTHOR Jens Helberg You can use this module under GNU public licence.}