using System;
using System.DirectoryServices;
namespace SystemFrameworks.Helper
{
///
///活动目录辅助类。封装一系列活动目录操作相关的方法。
///
public sealed class ADHelper
{
///
///域名
///
private static string DomainName = "MyDomain";
///
/// LDAP 地址
///
private static string LDAPDomain = "DC=MyDomain,DC=local";
///
/// LDAP绑定路径
///
private static string ADPath = "LDAP://brooks.mydomain.local";
///
///登录帐号
///
private static string ADUser = "Administrator";
///
///登录密码
///
private static string ADPassword = "password";
///
///扮演类实例
///
private static IdentityImpersonation impersonate = new IdentityImpersonation(ADUser, ADPassword, DomainName);
///
///用户登录验证结果
///
public enum LoginResult
{
///
///正常登录
///
LOGIN_USER_OK = 0,
///
///用户不存在
///
LOGIN_USER_DOESNT_EXIST,
///
///用户帐号被禁用
///
LOGIN_USER_ACCOUNT_INACTIVE,
///
///用户密码不正确
///
LOGIN_USER_PASSWORD_INCORRECT
}
///
///用户属性定义标志
///
public enum ADS_USER_FLAG_ENUM
{
///
///登录脚本标志。如果通过 ADSI LDAP 进行读或写操作时,该标志失效。如果通过 ADSI WINNT,该标志为只读。
///
ADS_UF_SCRIPT = 0X0001,
///
///用户帐号禁用标志
///
ADS_UF_ACCOUNTDISABLE = 0X0002,
///
///主文件夹标志
///
ADS_UF_HOMEDIR_REQUIRED = 0X0008,
///
///过期标志
///
ADS_UF_LOCKOUT = 0X0010,
///
///用户密码不是必须的
///
ADS_UF_PASSWD_NOTREQD = 0X0020,
///
///密码不能更改标志
///
ADS_UF_PASSWD_CANT_CHANGE = 0X0040,
///
///使用可逆的加密保存密码
///
ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = 0X0080,
///
///本地帐号标志
///
ADS_UF_TEMP_DUPLICATE_ACCOUNT = 0X0100,
///
///普通用户的默认帐号类型
///
ADS_UF_NORMAL_ACCOUNT = 0X0200,
///
///跨域的信任帐号标志
///
ADS_UF_INTERDOMAIN_TRUST_ACCOUNT = 0X0800,
///
///工作站信任帐号标志
///
ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0x1000,
///
///服务器信任帐号标志
///
ADS_UF_SERVER_TRUST_ACCOUNT = 0X2000,
///
///密码永不过期标志
///
ADS_UF_DONT_EXPIRE_PASSWD = 0X10000,
///
/// MNS 帐号标志
///
ADS_UF_MNS_LOGON_ACCOUNT = 0X20000,
///
///交互式登录必须使用智能卡
///
ADS_UF_SMARTCARD_REQUIRED = 0X40000,
///
///当设置该标志时,服务帐号(用户或计算机帐号)将通过 Kerberos 委托信任
///
ADS_UF_TRUSTED_FOR_DELEGATION = 0X80000,
///
///当设置该标志时,即使服务帐号是通过 Kerberos 委托信任的,敏感帐号不能被委托
///
ADS_UF_NOT_DELEGATED = 0X100000,
///
///此帐号需要 DES 加密类型
///
ADS_UF_USE_DES_KEY_ONLY = 0X200000,
///
///不要进行 Kerberos 预身份验证
///
ADS_UF_DONT_REQUIRE_PREAUTH = 0X4000000,
///
///用户密码过期标志
///
ADS_UF_PASSWORD_EXPIRED = 0X800000,
///
///用户帐号可委托标志
///
ADS_UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = 0X1000000
}
public ADHelper()
{
//
}
#region GetDirectoryObject
///
///获得DirectoryEntry对象实例,以管理员登陆AD
///
///
private static DirectoryEntry GetDirectoryObject()
{
DirectoryEntry entry = new DirectoryEntry(ADPath, ADUser, ADPassword, AuthenticationTypes.Secure);
return entry;
}
///
///根据指定用户名和密码获得相应DirectoryEntry实体
///
///
///
///
private static DirectoryEntry GetDirectoryObject(string userName, string password)
{
DirectoryEntry entry = new DirectoryEntry(ADPath, userName, password, AuthenticationTypes.None);
return entry;
}
///
/// i.e. /CN=Users,DC=creditsights, DC=cyberelves, DC=Com
///
///
///
private static DirectoryEntry GetDirectoryObject(string domainReference)
{
DirectoryEntry entry = new DirectoryEntry(ADPath + domainReference, ADUser, ADPassword, AuthenticationTypes.Secure);
return entry;
}
///
///获得以UserName,Password创建的DirectoryEntry
///
///
///
///
///
private static DirectoryEntry GetDirectoryObject(string domainReference, string userName, string password)
{
DirectoryEntry entry = new DirectoryEntry(ADPath + domainReference, userName, password, AuthenticationTypes.Secure);
return entry;
}
#endregion
#region GetDirectoryEntry
///
///根据用户公共名称取得用户的 对象
///
///
用户公共名称
///如果找到该用户,则返回用户的 对象;否则返回 null
public static DirectoryEntry GetDirectoryEntry(string commonName)
{
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(cn=" + commonName + "))";
deSearch.SearchScope = SearchScope.Subtree;
try
{
SearchResult result = deSearch.FindOne();
de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
}
///
///根据用户公共名称和密码取得用户的 对象。
///
///
用户公共名称
///
用户密码
///如果找到该用户,则返回用户的 对象;否则返回 null
public static DirectoryEntry GetDirectoryEntry(string commonName, string password)
{
DirectoryEntry de = GetDirectoryObject(commonName, password);
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(cn=" + commonName + "))";
deSearch.SearchScope = SearchScope.Subtree;
try
{
SearchResult result = deSearch.FindOne();
de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
}
///
///根据用户帐号称取得用户的 对象
///
///
用户帐号名
///如果找到该用户,则返回用户的 对象;否则返回 null
public static DirectoryEntry GetDirectoryEntryByAccount(string sAMAccountName)
{
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + sAMAccountName + "))";
deSearch.SearchScope = SearchScope.Subtree;
try
{
SearchResult result = deSearch.FindOne();
de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
}
///
///根据用户帐号和密码取得用户的 对象
///
///
用户帐号名
///
用户密码
///如果找到该用户,则返回用户的 对象;否则返回 null
public static DirectoryEntry GetDirectoryEntryByAccount(string sAMAccountName, string password)
{
DirectoryEntry de = GetDirectoryEntryByAccount(sAMAccountName);
if (de != null)
{
string commonName = de.Properties["cn"][0].ToString();
if (GetDirectoryEntry(commonName, password) != null)
return GetDirectoryEntry(commonName, password);
else
return null;
}
else
{
return null;
}
}
///
///根据组名取得用户组的 对象
///
///
组名
///
public static DirectoryEntry GetDirectoryEntryOfGroup(string groupName)
{
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(objectClass=group)(cn=" + groupName + "))";
deSearch.SearchScope = SearchScope.Subtree;
try
{
SearchResult result = deSearch.FindOne();
de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
}
#endregion
#region GetProperty
///
///获得指定 指定属性名对应的值
///
///
///
属性名称
///属性值
public static string GetProperty(DirectoryEntry de, string propertyName)
{
if(de.Properties.Contains(propertyName))
{
return de.Properties[propertyName][0].ToString() ;
}
else
{
return string.Empty;
}
}
///
///获得指定搜索结果 中指定属性名对应的值
///
///
///
属性名称
///属性值
public static string GetProperty(SearchResult searchResult, string propertyName)
{
if(searchResult.Properties.Contains(propertyName))
{
return searchResult.Properties[propertyName][0].ToString() ;
}
else
{
return string.Empty;
}
}
#endregion
///
///设置指定 的属性值
///
///
///
属性名称
///
属性值
public static void SetProperty(DirectoryEntry de, string propertyName, string propertyValue)
{
if(propertyValue != string.Empty || propertyValue != "" || propertyValue != null)
{
if(de.Properties.Contains(propertyName))
{
de.Properties[propertyName][0] = propertyValue;
}
else
{
de.Properties[propertyName].Add(propertyValue);
}
}
}
///
///创建新的用户
///
///
DN 位置。例如:OU=共享平台 或 CN=Users
///
公共名称
///
帐号
///
密码
///
public static DirectoryEntry CreateNewUser(string ldapDN, string commonName, string sAMAccountName, string password)
{
DirectoryEntry entry = GetDirectoryObject();
DirectoryEntry subEntry = entry.Children.Find(ldapDN);
DirectoryEntry deUser = subEntry.Children.Add("CN=" + commonName, "user");
deUser.Properties["sAMAccountName"].Value = sAMAccountName;
deUser.CommitChanges();
ADHelper.EnableUser(commonName);
ADHelper.SetPassword(commonName, password);
deUser.Close();
return deUser;
}
///
///创建新的用户。默认创建在 Users 单元下。
///
///
公共名称
///
帐号
///
密码
///
public static DirectoryEntry CreateNewUser(string commonName, string sAMAccountName, string password)
{
return CreateNewUser("CN=Users", commonName, sAMAccountName, password);
}
///
///判断指定公共名称的用户是否存在
///
///
用户公共名称
///如果存在,返回 true;否则返回 false
public static bool IsUserExists(string commonName)
{
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(cn=" + commonName + "))"; // LDAP 查询串
SearchResultCollection results = deSearch.FindAll();
if (results.Count == 0)
return false;
else
return true;
}
///
///判断用户帐号是否激活
///
///
用户帐号属性控制器
///如果用户帐号已经激活,返回 true;否则返回 false
public static bool IsAccountActive(int userAccountControl)
{
int userAccountControl_Disabled = Convert.ToInt32(ADS_USER_FLAG_ENUM.ADS_UF_ACCOUNTDISABLE);
int flagExists = userAccountControl & userAccountControl_Disabled;
if (flagExists > 0)
return false;
else
return true;
}
///
///判断用户与密码是否足够以满足身份验证进而登录
///
///
用户公共名称
///
密码
///如能可正常登录,则返回 true;否则返回 false
public static LoginResult Login(string commonName, string password)
{
DirectoryEntry de = GetDirectoryEntry(commonName);
if (de != null)
{
// 必须在判断用户密码正确前,对帐号激活属性进行判断;否则将出现异常。
int userAccountControl = Convert.ToInt32(de.Properties["userAccountControl"][0]);
de.Close();
if (!IsAccountActive(userAccountControl))
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;
if (GetDirectoryEntry(commonName, password) != null)
return LoginResult.LOGIN_USER_OK;
else
return LoginResult.LOGIN_USER_PASSWORD_INCORRECT;
}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}
///
///判断用户帐号与密码是否足够以满足身份验证进而登录
///
///
用户帐号
///
密码
///如能可正常登录,则返回 true;否则返回 false
public static LoginResult LoginByAccount(string sAMAccountName, string password)
{
DirectoryEntry de = GetDirectoryEntryByAccount(sAMAccountName);
if (de != null)
{
// 必须在判断用户密码正确前,对帐号激活属性进行判断;否则将出现异常。
int userAccountControl = Convert.ToInt32(de.Properties["userAccountControl"][0]);
de.Close();
if (!IsAccountActive(userAccountControl))
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;
if (GetDirectoryEntryByAccount(sAMAccountName, password) != null)
return LoginResult.LOGIN_USER_OK;
else
return LoginResult.LOGIN_USER_PASSWORD_INCORRECT;
}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}
///
///设置用户密码,管理员可以通过它来修改指定用户的密码。
///
///
用户公共名称
///
用户新密码
public static void SetPassword(string commonName, string newPassword)
{
DirectoryEntry de = GetDirectoryEntry(commonName);
// 模拟超级管理员,以达到有权限修改用户密码
impersonate.BeginImpersonate();
de.Invoke("SetPassword", new object[]{newPassword});
impersonate.StopImpersonate();
de.Close();
}
///
///设置帐号密码,管理员可以通过它来修改指定帐号的密码。
///
///
用户帐号
///
用户新密码
public static void SetPasswordByAccount(string sAMAccountName, string newPassword)
{
DirectoryEntry de = GetDirectoryEntryByAccount(sAMAccountName);
// 模拟超级管理员,以达到有权限修改用户密码
IdentityImpersonation impersonate = new IdentityImpersonation(ADUser, ADPassword, DomainName);
impersonate.BeginImpersonate();
de.Invoke("SetPassword", new object[]{newPassword});
impersonate.StopImpersonate();
de.Close();
}
///
///修改用户密码
///
///
用户公共名称
///
旧密码
///
新密码
public static void ChangeUserPassword (string commonName, string oldPassword, string newPassword)
{
// to-do: 需要解决密码策略问题
DirectoryEntry oUser = GetDirectoryEntry(commonName);
oUser.Invoke("ChangePassword", new Object[]{oldPassword, newPassword});
oUser.Close();
}
///
///启用指定公共名称的用户
///
///
用户公共名称
public static void EnableUser(string commonName)
{
EnableUser(GetDirectoryEntry(commonName));
}
///
///启用指定 的用户
///
///
public static void EnableUser(DirectoryEntry de)
{
impersonate.BeginImpersonate();
de.Properties["userAccountControl"][0] = ADHelper.ADS_USER_FLAG_ENUM.ADS_UF_NORMAL_ACCOUNT | ADHelper.ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD;
de.CommitChanges();
impersonate.StopImpersonate();
de.Close();
}
///
///禁用指定公共名称的用户
///
///
用户公共名称
public static void DisableUser(string commonName)
{
DisableUser(GetDirectoryEntry(commonName));
}
///
///禁用指定 的用户
///
///
public static void DisableUser(DirectoryEntry de)
{
impersonate.BeginImpersonate();
de.Properties["userAccountControl"][0]=ADHelper.ADS_USER_FLAG_ENUM.ADS_UF_NORMAL_ACCOUNT | ADHelper.ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD | ADHelper.ADS_USER_FLAG_ENUM.ADS_UF_ACCOUNTDISABLE;
de.CommitChanges();
impersonate.StopImpersonate();
de.Close();
}
///
///将指定的用户添加到指定的组中。默认为 Users 下的组和用户。
///
///
用户公共名称
///
组名
public static void AddUserToGroup(string userCommonName, string groupName)
{
DirectoryEntry oGroup = GetDirectoryEntryOfGroup(groupName);
DirectoryEntry oUser = GetDirectoryEntry(userCommonName);
impersonate.BeginImpersonate();
oGroup.Properties["member"].Add(oUser.Properties["distinguishedName"].Value);
oGroup.CommitChanges();
impersonate.StopImpersonate();
oGroup.Close();
oUser.Close();
}
///
///将用户从指定组中移除。默认为 Users 下的组和用户。
///
///
用户公共名称
///
组名
public static void RemoveUserFromGroup(string userCommonName, string groupName)
{
DirectoryEntry oGroup = GetDirectoryEntryOfGroup(groupName);
DirectoryEntry oUser = GetDirectoryEntry(userCommonName);
impersonate.BeginImpersonate();
oGroup.Properties["member"].Remove(oUser.Properties["distinguishedName"].Value);
oGroup.CommitChanges();
impersonate.StopImpersonate();
oGroup.Close();
oUser.Close();
}
}
///
///用户模拟角色类。实现在程序段内进行用户角色模拟。
///
public class IdentityImpersonation
{
[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public extern static bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
// 要模拟的用户的用户名、密码、域(机器名)
private String _sImperUsername;
private String _sImperPassword;
private String _sImperDomain;
// 记录模拟上下文
private WindowsImpersonationContext _imperContext;
private IntPtr _adminToken;
private IntPtr _dupeToken;
// 是否已停止模拟
private Boolean _bClosed;
///
///构造函数
///
///
所要模拟的用户的用户名
///
所要模拟的用户的密码
///
所要模拟的用户所在的域
public IdentityImpersonation(String impersonationUsername, String impersonationPassword, String impersonationDomain)
{
_sImperUsername = impersonationUsername;
_sImperPassword = impersonationPassword;
_sImperDomain = impersonationDomain;
_adminToken = IntPtr.Zero;
_dupeToken = IntPtr.Zero;
_bClosed = true;
}
///
///析构函数
///
~IdentityImpersonation()
{
if(!_bClosed)
{
StopImpersonate();
}
}
///
///开始身份角色模拟。
///
///
public Boolean BeginImpersonate()
{
Boolean bLogined = LogonUser(_sImperUsername, _sImperDomain, _sImperPassword, 2, 0, ref _adminToken);
if(!bLogined)
{
return false;
}
Boolean bDuped = DuplicateToken(_adminToken, 2, ref _dupeToken);
if(!bDuped)
{
return false;
}
WindowsIdentity fakeId = new WindowsIdentity(_dupeToken);
_imperContext = fakeId.Impersonate();
_bClosed = false;
return true;
}
///
///停止身分角色模拟。
///
public void StopImpersonate()
{
_imperContext.Undo();
CloseHandle(_dupeToken);
CloseHandle(_adminToken);
_bClosed = true;
}
}
}
=====================================================
简单的应用
[WebMethod]
public string IsAuthenticated(string UserID,string Password)
{
string _path = "LDAP://" + adm + "/DC=lamda,DC=com,DC=cn";//"LDAP://172.75.200.1/DC=名字,DC=com,DC=cn";
string _filterAttribute=null;
DirectoryEntry entry = new DirectoryEntry(_path,UserID,Password);
try
{
//Bind to the native AdsObject to force authentication.
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + UserID + ")";
SearchResult result = search.FindOne();
if(null == result)
{
_filterAttribute="登录失败: 未知的用户名或错误密码.";
}
else
{
_filterAttribute="true";
}
}
catch (Exception ex)
{
// if(ex.Message.StartsWith("该服务器不可操作"))
// {
// string mail = ADO.GetConnString("mail");
// entry.Path = "LDAP://"+mail+"/OU=名字,DC=it2004,DC=gree,DC=com,DC=cn";
// try
// {
// DirectorySearcher search = new DirectorySearcher(entry);
// search.Filter = "(SAMAccountName=" + UserID + ")";
// SearchResult result = search.FindOne();
//
// if(null == result)
// {
// _filterAttribute="登录失败: 未知的用户名或错误密码.";
// }
// else
// {
// _filterAttribute="true";
// }
// return _filterAttribute;
//
// }
// catch (Exception ex1)
// {
// return ex1.Message;
// }
//
// }
// else
return ex.Message;
}
return _filterAttribute;
}
[WebMethod]
public string[] LDAPMessage(string UserID)
{
string _path = "LDAP://"+adm+"/DC=it2004,DC=名字,DC=com,DC=cn";
string[] _filterAttribute=new string[5];
string[] msg = {"samaccountname","displayname","department","company"};
DirectoryEntry entry = new DirectoryEntry(_path,"180037","790813");
try
{
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + UserID + ")";
SearchResult result = search.FindOne();
if(null == result)
{
_filterAttribute[0]="登录失败: 未知的用户名或错误密码.";
}
else
{
_filterAttribute[0]="true";
for(int propertyCounter = 1; propertyCounter < 5; propertyCounter++)
{
if(propertyCounter==4 && result.Properties[msg[propertyCounter-1]][0]==null)
break;
_filterAttribute[propertyCounter]=result.Properties[msg[propertyCounter-1]][0].ToString();
}
}
}
catch (Exception ex)
{
//_filterAttribute[0]=ex.Message;
}
return _filterAttribute;
}
[WebMethod]
public string[] AllMembers()
{
string[] msg;
string _path = "LDAP://名字";
DirectoryEntry entry = new DirectoryEntry(_path,"180037","790813");
//Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = "(SAMAccountName=180037)";
msg=new string[mySearcher.FindAll().Count];
int i=0;
foreach(System.DirectoryServices.SearchResult result in mySearcher.FindAll())
{
msg[i++]=result.Path;
}
return msg;
}
}
C#操作域用户
转载于:https://www.cnblogs.com/zhjxiao/archive/2010/08/31/1813339.html
相关文章:

Redis进阶实践之三如何在Windows系统上安装安装Redis
一、Redis的简介 Redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/po…

31页PPT概述:图神经网络表达能力有多强?
整理 | 一一出品 | AI科技大本营近年来,图神经网络的研究成为深度学习领域的热点。图是一种数据结构,它对一组对象(节点)及其关系(边)进行建模,由于图结构的强大表现力,用机器学习方…

【linux】Linux kernel uapi header file(用户态头文件)
uapi目录的创建原因 Linux在3.7以后把很多header file移到 include/uapi或是arch/xxxx/include/uapi下,为了解决include recursive(循环包含头文件)的问题。 英文参考文档:https://lwn.net/Articles/507794/ 解决include recur…

诊断IIS中的ASP0115错误
诊断IIS中的ASP0115错误 作者:未知 重要说明:本文包含有关修改注册表的信息。修改注册表之前,一定要备份注册表,并且一定要知道在发生问题时如何还原注册表。有关如何备份、还原和编辑注册表的信息,请单击下面的文章…

【imx6】libipu.so.0说明
###代码位置 在目录fsl-release-bsp/build-fb/tmp/work/imx6qsabresd-poky-linux-gnueabi/imx-lib/1_3.14.28-1.0.0-r0/imx-lib-3.14.28-1.0.0/ipu中 编译完成后有如下文件列表 ipu$ ls Android.mk libipu.so Makefile mxc_ipu_hl_lib_dummy.c mxc_ipu_hl_lib.…

“安利”一款debug神器:在AI面前,bug都不是事儿
作者 | 琥珀出品 | AI科技大本营(公众号ID:rgznai100)为了帮程序员解决 bug 问题,Facebook 可算是操碎了心!你可以这么想,如果在开发和测试阶段没有发现 bug 问题,那么 bug 将会随着产品发布&am…

Spring中@Value用法收集
一、配置方式 Value需要参数,这里参数可以是两种形式: Value("#{configProperties[t1.msgname]}") 或者 Value("${t1.msgname}"); 这两形式,在配置上有什么区别: 1、Value("#{configPropert…

vue从入门到进阶:指令与事件(二)
一.插值 v-once 通过使用 v-once 指令,你也能执行一次性地插值,当数据改变时,插值处的内容不会更新。但请留心这会影响到该节点上所有的数据绑定: span v-once>这个将不会改变: {{ msg }}</span> v-html 双大括号会将数据…

【ubuntu工具】bless:二进制查看工具,类似win下的UltraEdit
###安装 sudo apt-get install bless 使用 bless filename 或者执行bless,在图形界面中打开准备操作的文件 工具主界面

马斯克连发三推,发布退出OpenAI内情
整理 | 一一出品 | AI科技大本营(ID:rgznai100)美国时间 2 月 17 日,特斯拉 CEO 马斯克在 Twitter 连发三帖,道出自己退出人工智能研究组织 OpenAI的缘由。他在推文中表示,他已经有一年多时间没有深度参与 OpenAI 事务…

开发代码命名规范!
今天查看以前的资料看见代码命名规范。呵呵 就拿出来给大家分享以下,还是比较老的。估计现在也是这种开发的命名规范。仅供参考!谢谢。 1.用Pascal规则来命名方法和类型。 public class DataGrid { public void DataBind() {…

【linux命令】readelf工具中英文说明
简介 readelf命令用来显示一个或者多个elf格式的目标文件的信息,可以通过它的选项来控制显示哪些信息。 ELF文件由4部分组成,分别是ELF头(ELF header)、程序头表(Program header table)、节(Se…

再见Python!Yann LeCun警告:深度学习需要新编程语言
整理 | 一一出品 | AI科技大本营尽管工程师们普遍定位 Python 是简单、优雅的编程语言,但它并非毫无缺点,比如人们一直吐槽它的执行速度不够快,线程不能利用多 CPU 等缺点,如今 AI 界泰斗也放话说要用新编程语言替代 Python。Face…

Linux系统与我之间的故事
2019独角兽企业重金招聘Python工程师标准>>> 说起Linux想必大家都不是很陌生的,关注这方面的不是大神就是对Linux特别热爱的人,那么接下来我给大家介绍下我和Linux之间的一些事,还有如何去快速的学习Linux。 我接触Linux大概就是大…
Google Instant 瞬时搜索上手指南
Google Instant是Google刚刚发布的一种新的搜索方式,随着你在搜索框里输入文字,Google将同时给出搜索结果,同时在搜索框里还会根据你输入的关键字给出搜索建议,通过上下键即可切换。按TAB键可自动补全第一位的搜索建议。随着你不断…

【视频】显示器固定参数struct fb_fix_screeninfo中char id[16]说明
imx6q关于fb和video的设备信息 设备节点 root@myzr:/unit_tests# ls /dev/fb* -l lrwxrwxrwx 1 root root 3 Jan 1 1970 /dev/fb -> fb0 crw-rw---- 1 root video 29, 0 Jan 1 1970 /dev/fb0 crw-rw---- 1 root video 29, 1 Jan 1 1970 /dev/fb1 crw-rw---- 1 …

“编程不规范,同事两行泪!”
【编者按】编程江湖中一直盛传着一个段子,那就是要问程序员最讨厌哪 4 件事?那必须是:写注释、写文档、别人不写注释、别人不写文档。更甚者,在《流浪地球》形成刷屏之势之后,仿其而出的“代码千万行,注释第…

记一次 调节有音量界面 上移的bug
如图所示:音量调节的界面直接上移了本来是以为是因为edittext 的原因使得这个界面上移了(但其实我也不信,因为我应该影响不了系统的界面) 然后最后不断调整布局 不断调整代码 通过排查 发现是因为使用了DTMF的原因(用来…

这可能是史上最全的Python算法集!
来源 | CSDN(ID:CSDNnews )本文是一些机器人算法(特别是自动导航算法)的Python代码合集。其主要特点有以下三点:选择了在实践中广泛应用的算法;依赖最少;容易阅读,容易理…

Emoji表情图标在iOS与PHP之间通信及MySQL存储
在某个 iOS 项目中,需要一个服务器来保存一些用户数据,例如用户信息、评论等,我们的服务器端使用了 PHPMySQL 的搭配。在测试过程中我们发现,用户在 iOS 端里输入了 Emoji 表情提交到服务器以后,PHP 无法在 MySQL 数据…

【linux】图形界面基础知识(X、X11、GNOME、Xorg、KDE的概念和它们之间的关系)
转载自:https://blog.csdn.net/zhangxinrun/article/details/7332049 简介 LINUX初学者经常分不清楚linux和X之间,X和Xfree86之间,X和KDE,GNOME等之间是什么关系。常常混淆概念,本文以比较易于理解的方式来解释X&…

DreamWeaver做ASP 第13页
第七步:修改资料篇 修改资料!首先要清醒一点,什么人才可以修改。 一,本人只能修改自己的;二,管理员可以修改所有人的。 那今天先来搞个可以修改自己资料的页面。 顺序是:先确认是正确登录&#…

【linux命令】setterm控制终端属性命令(中英文)
###setterm中文 SETTERM(1) 用户命令 SETTERM(1) 名字 setterm - 设置终端属性 概要 setterm [选项] 描述 setterm向终端写一个字符串到标准输出,调用终端的特定功能。在虚拟终端上使用,将会改变虚拟终端的输出特性。不支持的选项将被忽略。 选项 对…

搜狗分身技术再进化,让AI合成主播“动”起来
整理 | 一一出品 | AI科技大本营去年 11 月的互联网大会期间,搜狗与新华社联合发布全球首个AI合成主播一经亮相,引起了人们对“AI媒体”的广泛讨论。如今,搜狗 AI 合成主播不断更新迭代。2 月 19 日,在新华社新媒体中心与搜狗公司…

Angular http跨域
var app angular.module(Mywind,[ui.router]); app.controller(Myautumn,function($scope,$http,$filter){ //$http跨域 //服务端设置 // 访问权限 response.setHeader("Access-Control-Allow-Origin", "*"); // 访问类型 response.setHeader(&q…

文本分类step by step(二)
(注:如有转载请标明作者:finallyliuyu, 和出处:博客园) 《文本分类 step by step(一)》 在《文本分类step by step(一)》中,我们从处理语料库开始讲起,一直讲到利用分类器…

Centos7.4 版本环境下安装Mysql5.7操作记录
Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所不同的,废话就不多赘述了,下面介绍下在centos7.x环境里安装mysql5.7的几种方法:一、yum方式安装 Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所…

叫你一声“孙悟空”,敢答应么?
整理 | 一一出品 | AI科技大本营(ID:rgznai100)随着自然语言理解等技术的发展,对话机器人如今盛行,而基于此的智能音箱产品的发展也异常火热。很多开发者一般热衷于在一些对话机器人平台上开发相应的语音技能,但也有不…

【linux】Matchbox(一):启动脚本
脚本执行顺序 启动X服务器 /etc/rc5.d/S01xserver-nodm --> …/init.d/xserver-nodm–> 对应进程: /bin/sh /etc/rc5.d/S01xserver-nodm start background xinit /etc/X11/Xsession–> 对应进程: xinit /etc/X11/Xsession – /usr/bin/Xorg …

java试用(1)hello world
设置环境变量path H:\soft\j2sdk1.4.2_17\bin;H:\soft\eclipse;%path%set CLASSPATH.;H:\soft\j2sdk1.4.2_17\jre\lib;JAVA_HOME: D:\jdk1.5.0PATH: D:\jdk1.5.0\bin;编写程序 Noname1.java (注意:文件名要和class名一样)class Noname1 { public static void…