@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Validate if a name is in a valid format and if its in use. !!!!C# Signature: [DllImport("netapi32.dll", SetLastError=true,CharSet=CharSet.Unicode)] static extern UInt32 NetValidateName(string lpServer,string lpName, string lpAccount,string lpPassword, int NameType); static extern UInt32 NetValidateName(string lpServer,string lpName, string lpAccount,string lpPassword, NET_SETUP_NAMETYPE NameType); !!!!VB Signature: !!!!Powershell: Add-Type -TypeDefinition @" using System; using System.Runtime.InteropServices; public class NetworkUtil { [DllImport("Netapi32.dll",CharSet=CharSet.Unicode)] public static extern UInt32 NetValidateName(string lpServer,string lpName,string lpAccount,string lpPassword, int NameType); } !!!!User-Defined Types: ENUM NET_SETUP_NAMETYPE{ NetSetupUnknown, NetSetupMachine, NetSetupWorkgroup, NetSetupDomain, NetSetupNonExistentDomain, NetSetupDnsMachine} !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: Most useful NameType's are 1 and 3 which will allow you to see if the name is in use. !!!!Tips & Tricks: Please add some! !!!!Sample Code: using System; using System.Runtime.InteropServices; public class NetworkUtil { [DllImport("Netapi32.dll",SetLastError=true,CharSet=CharSet.Unicode)] public static extern UInt32 NetValidateName(string lpServer,string lpName, string lpAccount,string lpPassword, int NameType); static void Main() { UInt32 rtn = NetValidateName(null, "jrich523.wordpress.com", null, null, 3); Console.WriteLine(rtn); Console.ReadKey(); } } !!!!POWERSHELL Code Example: Add-Type -TypeDefinition @" using System; using System.Runtime.InteropServices; public class NetworkUtil { [DllImport("Netapi32.dll",CharSet=CharSet.Unicode)] public static extern UInt32 NetValidateName(string lpServer,string lpName,string lpAccount,string lpPassword, int NameType); } "@ Function Test-NetBIOSName{ param([string] $Name, [int] $NameType) [NetworkUtil]::NetValidateName($null,$name,$null,$null,$NameType) } #TEST Test-NetBIOSName “myserver” 1 Documentation: NetValidateName@msdn on MSDN
Edit netapi32.NetValid...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.