网站首页  词典首页

请输入您要查询的函数:

 

术语 netvalidatename
释义 NetValidateName
语法:
C++
NET_API_STATUS NetValidateName(
__in LPCWSTR lpServer,
__in LPCWSTR lpName,
__in LPCWSTR lpAccount,
__in LPCWSTR lpPassword,
__in NETSETUP_NAME_TYPE NameType
);
NetValidateName功能
该NetValidateName功能验证的名称为指定(计算机名,工作组名,域名,计算机名称或DNS)名称类型有效。
参数
lpServer [in]
一个常量字符串,它指定的DNS或NetBIOS的计算机上调用函数名的指针。如果该参数为NULL,则使用本地计算机。
lpName [in]
一个字符串常量,指定的名称来验证的指针。根据在NameType参数指定的值,lpName参数可以指向一个计算机名,工作组名,域名,或DNS计算机名称。
lpAccount [in]
如果lpName参数是一个域名,一个帐户名点,此参数时使用的连接到域控制器。该字符串必须指定一个域的NetBIOS名称和用户帐户(例如,“雷德蒙德\\用户”)或用户主要名称(UPN)在一个互联网的形式向用户式(例如登录名,“有人@ example.com“)。如果该参数为NULL,则调用方的上下文被使用。
lpPassword [in]
如果lpAccount参数指定的帐户名,此参数必须指向要使用的密码当连接到域控制器。否则,此参数必须为NULL。
NameType [in]
在参数传递的lpName验证名称类型。此参数可从NETSETUP_NAME_TYPE枚举在Lmjoin.h头文件中定义的类型的值之一。
请注意,Lmjoin.h头自动由Lm.h头文件中。头文件的Lmjoin.h不能直接使用。
下面的列表显示此参数的可能值。
ValueMeaning
NetSetupUnknown
0The nametype的是未知的。如果此值使用时,NetValidateName函数失败,ERROR_INVALID_PARAMETER。
NetSetupMachine
1Verify的NetBIOS计算机名称是有效的,它不是使用。
NetSetupWorkgroup
2Verify该工作组的名称是有效的。
NetSetupDomain
3Verify该域名是否存在,它是一个域。
NetSetupNonExistentDomain
4Verify该域名不在使用。
NetSetupDnsMachine
5Verify的DNS计算机的名称是有效的。
此值是支持Windows 2000和更高版本。应用程序必须编译_WIN32_WINNT“= 0x0500使用此值。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
DNS_ERROR_INVALID_NAME_CHARThe DNS名称包含无效字符。返回此错误,如果NameType参数指定NetSetupDnsMachine和lpName参数的DNS名称包含无效字符。
DNS_ERROR_NON_RFC_NAMEThe DNS名称不符合RFC规范。返回此错误,如果NameType参数指定NetSetupDnsMachine和lpName参数DNS名称不符合RFC规范。
ERROR_DUP_NAMEA已经存在重复的名称在网络上。
ERROR_INVALID_COMPUTERNAMEThe指定的计算机名的格式无效。
ERROR_INVALID_PARAMETERA参数不正确。返回此错误,如果lpName参数为NULL或NameType参数是NetSetupUnknown或未知nametype指定。
ERROR_NO_SUCH_DOMAINThe指定的域不存在。
ERROR_NOT_SUPPORTEDThe不支持请求。返回此错误,如果是远程计算机中指定lpServer参数,这一呼吁是在远程计算机上的支持。
NERR_InvalidComputerThe指定的计算机名称无效。返回此错误,如果NameType参数指定NetSetupDnsMachine或NetSetupMachine和指定的计算机的名称是无效的。
NERR_InvalidWorkgroupNameThe指定的工作组名称无效。返回此错误,如果NameType参数指定NetSetupWorkgroup和指定工作组名称是无效的。
RPC_S_SERVER_UNAVAILABLEThe RPC服务器不可用。返回此错误,如果是远程计算机中指定lpServer参数和RPC服务器不可用。
RPC_E_REMOTE_DISABLEDRemote呼吁不允许这一进程。返回此错误,如果是远程计算机中指定lpServer参数和远程调用不容许这一进程。
备注
函数验证的NetValidateName在指定nametype为基础的名称。
如果NameType参数NetSetupMachine,名称传递的lpName参数必须语法作为NetBIOS名称和正确的名称不得目前在网络上使用。
如果NameType参数NetSetupWorkgroup,在lpName参数传递的名称必须是一个语法正确的NetBIOS名称,该名称必须在目前尚未就作为一个独特的名称网络使用的名称必须从计算机名称不同。
如果NameType参数NetSetupDomain,在lpName参数传递的名称必须是语法作为NetBIOS或DNS名称,名称必须正确,目前注册为域名。
如果NameType参数NetSetupNonExistentDomain,在lpName参数传递的名称必须是语法作为NetBIOS或DNS名称,名称目前不正确的,必须注册为域名。
如果NameType参数NetSetupDnsMachine,名称传递的lpName参数必须作为一个语法正确的DNS名称。
NetBIOS名称被限制为16个字符的最大长度。
没有特殊组成员必须成功地执行NetValidateName功能。
实例
下面的例子验证了特定类型的名称。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
#include
int wmain(int argc, wchar_t * argv[])
{
NET_API_STATUS nStatus;
LPCWSTR lpServer = NULL;
LPCWSTR lpName = NULL;
LPCWSTR lpAccount = NULL;
LPCWSTR lpPassword = NULL;
DWORD dwNameType = NetSetupUnknown; // unknown name type
if (argc != 3 && argc != 4 && argc != 6) {
wprintf(L"Usage: %ws Server Name AccountName Password> nametype\\n",
argv[0]);
wprintf(L"Usage: %ws Server Name nametype\\n", argv[0]);
wprintf(L"Usage: %ws Name nametype\\n", argv[0]);
wprintf(L" %ws Client2 2\\n", argv[0]);
wprintf(L" %ws Myserver Client2 3\\n", argv[0]);
wprintf(L" %ws Myserver Client2 domain\\\\user password 3\\n", argv[0]);
exit(1);
}
// The request is not for the primary domain.
//
if (argc == 3) {
lpName = argv[1];
dwNameType = _wtoi(argv[2]);
}
if (argc == 4) {
lpServer = argv[1];
lpName = argv[2];
dwNameType = _wtoi(argv[3]);
}
if (argc == 6) {
lpServer = argv[1];
lpName = argv[2];
lpAccount = argv[3];
lpPassword = argv[4];
dwNameType = _wtoi(argv[5]);
}
wprintf(L"Calling NetValidateName with parameters\\n");
wprintf(L" lpServer = %ws\\n", lpServer);
wprintf(L" lpName = %ws\\n", lpName);
wprintf(L" lpAccount = %ws\\n", lpAccount);
wprintf(L" lpPassword = %ws\\n", lpPassword);
wprintf(L" NameType = %d ", dwNameType);
switch (dwNameType) {
case NetSetupUnknown:
wprintf(L"(NetSetupUnknown)\\n");
break;
case NetSetupMachine:
wprintf(L"(NetSetupMachine)\\n");
break;
case NetSetupWorkgroup:
wprintf(L"(NetSetupWorkgroup)\\n");
break;
case NetSetupDomain:
wprintf(L"(NetSetupDomain)\\n");
break;
case NetSetupNonExistentDomain:
wprintf(L"(NetSetupNonExistentDomain)\\n");
break;
#if(_WIN32_WINNT >= 0x0500)
case NetSetupDnsMachine:
wprintf(L"(NetSetupDnsMachine)\\n");
break;
#endif
default:
wprintf(L"Other unknown nametype)\\n");
break;
}
//
// Call the NetValidateName function to validate the name
//
nStatus = NetValidateName(lpServer,
lpName, lpAccount, lpPassword, (NETSETUP_NAME_TYPE) dwNameType);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success)) {
wprintf(L"NetValidateName was successful\\n", nStatus);
} else {
wprintf(L"NetValidateName failed with error: %lu (0x%lx)\\n", nStatus,
nStatus);
wprintf(L" Error = ");
switch (nStatus) {
case ERROR_INVALID_PARAMETER:
wprintf(L"ERROR_INVALID_PARAMETER\\n");
break;
case ERROR_DUP_NAME:
wprintf(L"ERROR_DUP_NAME\\n");
break;
case ERROR_NO_SUCH_DOMAIN:
wprintf(L"ERROR_NO_SUCH_DOMAIN\\n");
break;
case ERROR_NOT_SUPPORTED:
wprintf(L"ERROR_NOT_SUPPORTED\\n");
break;
case ERROR_INVALID_COMPUTERNAME:
wprintf(L"ERROR_INVALID_COMPUTERNAME\\n");
break;
case DNS_ERROR_INVALID_NAME_CHAR:
wprintf(L"DNS_ERROR_INVALID_NAME_CHAR\\n");
break;
case DNS_ERROR_NON_RFC_NAME:
wprintf(L"DNS_ERROR_NON_RFC_NAME\\n");
break;
case NERR_InvalidComputer:
wprintf(L"NERR_InvalidComputer\\n");
break;
case NERR_InvalidWorkgroupName:
wprintf(L"NERR_InvalidWorkgroupName\\n");
break;
case RPC_S_SERVER_UNAVAILABLE:
wprintf(L"RPC_S_SERVER_UNAVAILABLE\\n");
break;
case RPC_E_REMOTE_DISABLED:
wprintf(L"RPC_E_REMOTE_DISABLED\\n");
break;
default:
wprintf(L"Other error, see Winerror.h or lmerr.h)\\n");
break;
}
}
return nStatus;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmjoin.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
目录服务功能
NetGetJoinableOUs
NetGetJoinInformation
NetJoinDomain
NetRenameMachineInDomain
NetUnjoinDomain
网络管理概述
网络管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetValidateName Function
The NetValidateName function verifies that a name is valid for name type specified(computer name, workgroup name, domain name, or DNS computer name).
Syntax
C++
NET_API_STATUS NetValidateName(
__in LPCWSTR lpServer,
__in LPCWSTR lpName,
__in LPCWSTR lpAccount,
__in LPCWSTR lpPassword,
__in NETSETUP_NAME_TYPE NameType
);
Parameters
lpServer [in]
A pointer to a constant string that specifies the DNS or NetBIOS name of the computer on which to call the function. If this parameter is NULL, the local computer is used.
lpName [in]
A pointer to a constant string that specifies the name to validate. Depending on the value specified in the NameType parameter, the lpName parameter can point to a computer name, workgroup name, domain name, or DNS computer name.
lpAccount [in]
If the lpName parameter is a domain name, this parameter points to an account name to use when connecting to the domain controller. The string must specify either a domain NetBIOS name and user account (for example, "REDMOND\\user") or the user principal name (UPN) of the user in the form of an Internet-style login name (for example, "someone@example.com"). If this parameter is NULL, the caller's context is used.
lpPassword [in]
If the lpAccount parameter specifies an account name, this parameter must point to the password to use when connecting to the domain controller. Otherwise, this parameter must be NULL.
NameType [in]
The type of the name passed in the lpName parameter to validate. This parameter can be one of the values from the NETSETUP_NAME_TYPE enumeration type defined in the Lmjoin.h header file.
Note that the Lmjoin.h header is automatically included by the Lm.h header file. The Lmjoin.h header files should not be used directly.
The following list shows the possible values for this parameter.
ValueMeaning
NetSetupUnknown
0The nametype is is unknown. If this value is used, the NetValidateName function fails with ERROR_INVALID_PARAMETER.
NetSetupMachine
1Verify that the NetBIOS computer name is valid and that it is not in use.
NetSetupWorkgroup
2Verify that the workgroup name is valid.
NetSetupDomain
3Verify that the domain name exists and that it is a domain.
NetSetupNonExistentDomain
4Verify that the domain name is not in use.
NetSetupDnsMachine
5Verify that the DNS computer name is valid.
This value is supported on Windows 2000 and later. The application must be compiled with _WIN32_WINNT >= 0x0500 to use this value.

Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Return codeDescription
DNS_ERROR_INVALID_NAME_CHARThe DNS name contains an invalid character. This error is returned if the NameType parameter specified is NetSetupDnsMachine and the DNS name in the lpName parameter contains an invalid character.
DNS_ERROR_NON_RFC_NAMEThe DNS name does not comply with RFC specifications. This error is returned if the NameType parameter specified is NetSetupDnsMachine and the DNS name in the lpName parameter does not comply with RFC specifications.
ERROR_DUP_NAMEA duplicate name already exists on the network.
ERROR_INVALID_COMPUTERNAMEThe format of the specified computer name is not valid.
ERROR_INVALID_PARAMETERA parameter is incorrect. This error is returned if the lpName parameter is NULL or the NameType parameter is specified as NetSetupUnknown or an unknown nametype.
ERROR_NO_SUCH_DOMAINThe specified domain does not exist.
ERROR_NOT_SUPPORTEDThe request is not supported. This error is returned if a remote computer was specified in the lpServer parameter and this call is not supported on the remote computer.
NERR_InvalidComputerThe specified computer name is not valid. This error is returned if the NameType parameter specified is NetSetupDnsMachine or NetSetupMachine and the specified computer name is not valid.
NERR_InvalidWorkgroupNameThe specified workgroup name is not valid. This error is returned if the NameType parameter specified is NetSetupWorkgroup and the specified workgroup name is not valid.
RPC_S_SERVER_UNAVAILABLEThe RPC server is not available. This error is returned if a remote computer was specified in the lpServer parameter and the RPC server is not available.
RPC_E_REMOTE_DISABLEDRemote calls are not allowed for this process. This error is returned if a remote computer was specified in the lpServer parameter and remote calls are not allowed for this process.

Remarks
The NetValidateName function validates a name based on the nametype specified.
If the NameType parameter is NetSetupMachine, the name passed in the lpName parameter must be syntactically correct as a NetBIOS name and the name must not currently be in use on the network.
If the NameType parameter is NetSetupWorkgroup, the name passed in the lpName parameter must be syntactically correct as a NetBIOS name, the name must not currently be in use on the network as a unique name, and the name must be different from the computer name.
If the NameType parameter is NetSetupDomain, the name passed in the lpName parameter must be syntactically correct as a NetBIOS or DNS name and the name must currently be registered as a domain name.
If the NameType parameter is NetSetupNonExistentDomain, the name passed in the lpName parameter must be syntactically correct as a NetBIOS or DNS name and the name must currently not be registered as a domain name.
If the NameType parameter is NetSetupDnsMachine, the name passed in the lpName parameter must be syntactically correct as a DNS name.
NetBIOS names are limited to maximum length of 16 characters.
No special group membership is required to successfully execute the NetValidateName function.
Examples
The following example validates a name for a specific type.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
#include
int wmain(int argc, wchar_t * argv[])
{
NET_API_STATUS nStatus;
LPCWSTR lpServer = NULL;
LPCWSTR lpName = NULL;
LPCWSTR lpAccount = NULL;
LPCWSTR lpPassword = NULL;
DWORD dwNameType = NetSetupUnknown; // unknown name type
if (argc != 3 && argc != 4 && argc != 6) {
wprintf(L"Usage: %ws Server Name AccountName Password> nametype\\n",
argv[0]);
wprintf(L"Usage: %ws Server Name nametype\\n", argv[0]);
wprintf(L"Usage: %ws Name nametype\\n", argv[0]);
wprintf(L" %ws Client2 2\\n", argv[0]);
wprintf(L" %ws Myserver Client2 3\\n", argv[0]);
wprintf(L" %ws Myserver Client2 domain\\\\user password 3\\n", argv[0]);
exit(1);
}
// The request is not for the primary domain.
//
if (argc == 3) {
lpName = argv[1];
dwNameType = _wtoi(argv[2]);
}
if (argc == 4) {
lpServer = argv[1];
lpName = argv[2];
dwNameType = _wtoi(argv[3]);
}
if (argc == 6) {
lpServer = argv[1];
lpName = argv[2];
lpAccount = argv[3];
lpPassword = argv[4];
dwNameType = _wtoi(argv[5]);
}
wprintf(L"Calling NetValidateName with parameters\\n");
wprintf(L" lpServer = %ws\\n", lpServer);
wprintf(L" lpName = %ws\\n", lpName);
wprintf(L" lpAccount = %ws\\n", lpAccount);
wprintf(L" lpPassword = %ws\\n", lpPassword);
wprintf(L" NameType = %d ", dwNameType);
switch (dwNameType) {
case NetSetupUnknown:
wprintf(L"(NetSetupUnknown)\\n");
break;
case NetSetupMachine:
wprintf(L"(NetSetupMachine)\\n");
break;
case NetSetupWorkgroup:
wprintf(L"(NetSetupWorkgroup)\\n");
break;
case NetSetupDomain:
wprintf(L"(NetSetupDomain)\\n");
break;
case NetSetupNonExistentDomain:
wprintf(L"(NetSetupNonExistentDomain)\\n");
break;
#if(_WIN32_WINNT >= 0x0500)
case NetSetupDnsMachine:
wprintf(L"(NetSetupDnsMachine)\\n");
break;
#endif
default:
wprintf(L"Other unknown nametype)\\n");
break;
}
//
// Call the NetValidateName function to validate the name
//
nStatus = NetValidateName(lpServer,
lpName, lpAccount, lpPassword, (NETSETUP_NAME_TYPE) dwNameType);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success)) {
wprintf(L"NetValidateName was successful\\n", nStatus);
} else {
wprintf(L"NetValidateName failed with error: %lu (0x%lx)\\n", nStatus,
nStatus);
wprintf(L" Error = ");
switch (nStatus) {
case ERROR_INVALID_PARAMETER:
wprintf(L"ERROR_INVALID_PARAMETER\\n");
break;
case ERROR_DUP_NAME:
wprintf(L"ERROR_DUP_NAME\\n");
break;
case ERROR_NO_SUCH_DOMAIN:
wprintf(L"ERROR_NO_SUCH_DOMAIN\\n");
break;
case ERROR_NOT_SUPPORTED:
wprintf(L"ERROR_NOT_SUPPORTED\\n");
break;
case ERROR_INVALID_COMPUTERNAME:
wprintf(L"ERROR_INVALID_COMPUTERNAME\\n");
break;
case DNS_ERROR_INVALID_NAME_CHAR:
wprintf(L"DNS_ERROR_INVALID_NAME_CHAR\\n");
break;
case DNS_ERROR_NON_RFC_NAME:
wprintf(L"DNS_ERROR_NON_RFC_NAME\\n");
break;
case NERR_InvalidComputer:
wprintf(L"NERR_InvalidComputer\\n");
break;
case NERR_InvalidWorkgroupName:
wprintf(L"NERR_InvalidWorkgroupName\\n");
break;
case RPC_S_SERVER_UNAVAILABLE:
wprintf(L"RPC_S_SERVER_UNAVAILABLE\\n");
break;
case RPC_E_REMOTE_DISABLED:
wprintf(L"RPC_E_REMOTE_DISABLED\\n");
break;
default:
wprintf(L"Other error, see Winerror.h or lmerr.h)\\n");
break;
}
}
return nStatus;
}

Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmjoin.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Directory Service Functions
NetGetJoinableOUs
NetGetJoinInformation
NetJoinDomain
NetRenameMachineInDomain
NetUnjoinDomain
Network Management Overview
Network Management Functions
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370660(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2025/1/8 10:48:17