问题描述
DC裏包含兩個NETBIOS名,分別是PROD和TEST.假設DC名是XXX.ORG.程序要求:把所有與AccountName=xxxxx同一層級的員工的AccountUnlock程序如下:stringDomainName="TEST.XXX.ORG";stringFilterStr="(sAMAccountname=xxxxx)";DirectorySearcherSearcher=newDirectorySearcher(DomainName);Searcher.Filter=FilterStr;SearchResultSearchRes=Searcher.FindOne();DirectoryEntryMe=SearchRes.GetDirectoryEntry();stringOUPath=Me.Parent.Path;stringUsername="MyUserName";stringPassword="MyPassword";DirectoryEntryAdminEntry=newDirectoryEntry(OUPath,Username,Password);foreach(DirectoryEntryTempEntryinAdminEntry.Children){if(TempEntry.SchemaClassName.ToString()=="user"){try{TempEntry.Properties["LockOutTime"].Value=0;//UnlockAccountTempEntry.CommitChanges();TempEntry.Close();}catch(System.DirectoryServices.DirectoryServicesCOMExceptionE){Console.WriteLine(E.Message);}}}當程序運行到紅色那一行代碼的時候,便出現UnknownUsernameOrBadPassowrd.但我的帳戶跟密碼是肯定沒錯的.這是甚麼問題呢?跟我在本機LoginwithDomainPROD有關嗎?求高手回覆m(__)m
解决方案
解决方案二:
加上这个看看把stringDomainName="TEST.XXX.ORG";改成stringDomainName="LADP://TEST.XXX.ORG";试一下