Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.fds-net.ru/showflat.php?Number=2166549&src=arc&showlite=
Дата изменения: Unknown
Дата индексирования: Wed Apr 13 09:04:36 2016
Кодировка: Windows-1251
Active Directory смена пароля - Public forum of MSU united student networks
Root | Google | Yandex | Mail.ru | Kommersant | Afisha | LAN Support
  
Technical >> Development (Archive)

Страницы: 1
Shurik

Рег.: 27.09.2003
Сообщений: 13646
Рейтинг: 787
  Active Directory смена пароля
      10.01.2005 20:28
 

может кто-нибудь сталкивался с такой проблемой, напишите пожалуйста код, который меняет пароль
и Интернете об этом много написано, но я так и не разобрался



not fluffing up the experience with features that will ultimately cause you a headache
ihanic
enthusiast

Рег.: 11.09.2004
Сообщений: 202
Из: Russia Federation
Рейтинг: 23
  Re: Active Directory смена пароля [re: Shurik]
      10.01.2005 20:55
 

Апишник через COM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/using_adsi.asp

возвращаясь к смене пароля
changing_the_password_on_a_serviceampaposs_user_account.asp

цитата с сайта
code:
DWORD UpdateAccountPassword( LPTSTR szServerDNS, // DNS name of host computer LPTSTR szAccountDN, // Distinguished name of service logon account LPTSTR szServiceName, // Name of the service LPTSTR szOldPassword, // Old password LPTSTR szNewPassword // New password ) { SC_HANDLE schService = NULL; SC_HANDLE schSCManager = NULL; DWORD dwLen = MAX_PATH; TCHAR szAccountPath[MAX_PATH]; IADsUser *pUser = NULL; HRESULT hr; DWORD dwStatus=0; SC_LOCK sclLock = NULL; if(!szServerDNS || !szAccountDN || !szServiceName || !szOldPassword || !szNewPassword) { _tprintf(TEXT("Invalid parameter")); goto cleanup; } // Set the password on the account. // Use the distinguished name to bind to the account object. _tcsncpy(szAccountPath, TEXT("LDAP://"), MAX_PATH); _tcscat(szAccountPath, szAccountDN, MAX_PATH - _tcslen(szAccountPath)); hr = ADsGetObject(szAccountPath, IID_IADsUser, (void**)&pUser); if (FAILED(hr)) { _tprintf(TEXT("Get IADsUser failed - 0x%x\n"), dwStatus = hr); goto cleanup; } // Set the password on the account. hr = pUser->ChangePassword(CComBSTR(szOldPassword), CComBSTR(szNewPassword)); if (FAILED(hr)) { _tprintf(TEXT("ChangePassword failed - 0x%x\n"), dwStatus = hr); goto cleanup; } // Update the account and password in the SCM database. // Open the Service Control Manager on the specified computer. schSCManager = OpenSCManager( szServerDNS, // DNS name of host computer NULL, // database (NULL == default) SC_MANAGER_ALL_ACCESS // access required ); if (! schSCManager) { _tprintf(TEXT("OpenSCManager failed - %d\n"), dwStatus = GetLastError()); goto cleanup; } // Open a handle to the service instance. schService = OpenService(schSCManager, szServiceName, SERVICE_ALL_ACCESS); if (! schService) { _tprintf(TEXT("OpenService failed - %s\n"), dwStatus = GetLastError()); goto cleanup; } // Get the SCM database lock before changing the password. sclLock = LockServiceDatabase(schSCManager); if (sclLock == NULL) { _tprintf(TEXT("LockServiceDatabase failed - %d\n"), dwStatus = GetLastError()); goto cleanup; } // Set the account and password that the service uses at startup. if (! ChangeServiceConfig( schService, // Handle of service SERVICE_NO_CHANGE, // Service type: no change SERVICE_NO_CHANGE, // Change service start type SERVICE_NO_CHANGE, // Error control: no change NULL, // Binary path: no change NULL, // Load order group: no change NULL, // Tag ID: no change NULL, // Dependencies: no change NULL, // Account name: no change szNewPassword, // New password NULL) ) { // Display name: no change _tprintf(TEXT("ChangeServiceConfig failed - %s\n"), dwStatus = GetLastError()); goto cleanup; } _tprintf(TEXT("Password changed for service instance on: %s\n"), szServerDNS); cleanup: if (sclLock) UnlockServiceDatabase(sclLock); if (schService) CloseServiceHandle(schService); if (schSCManager) CloseServiceHandle(schSCManager); if (pUser) pUser->Release(); return dwStatus; }




докажи все себе.
ykpon
Carpal Tunnel

Рег.: 29.08.2002
Сообщений: 6503
Рейтинг: 222
  Re: Active Directory смена пароля [re: Shurik]
      10.01.2005 21:27
 

код на чем ?

ihanic
enthusiast

Рег.: 11.09.2004
Сообщений: 202
Из: Russia Federation
Рейтинг: 23
  Re: Active Directory смена пароля [re: ykpon]
      10.01.2005 21:28
 

C с использованием COM (можно адаптировать практически под любые языки хоть на перл переписать)





Редактировал ihanic (10.01.2005 21:44)
докажи все себе.
Shurik

Рег.: 27.09.2003
Сообщений: 13646
Рейтинг: 787
  Re: Active Directory смена пароля [re: ihanic]
      10.01.2005 21:54
 

желательно конечно на .Net



not fluffing up the experience with features that will ultimately cause you a headache
ihanic
enthusiast

Рег.: 11.09.2004
Сообщений: 202
Из: Russia Federation
Рейтинг: 23
  Re: Active Directory смена пароля [re: Shurik]
      10.01.2005 22:13
 

Есть Хороший сайт
code:
using System; using System.DirectoryServices; namespace OLAActiveDirectory.Management { public interface IADPasswdManager { void ChangePassword(IADUser objUser,string strOldPasswd,string strNewPasswd); void SetPassword(IADUser objUser,string strPasswd); } public class ADPasswdManager : IADPasswdManager { public ADPasswdManager() { } public void SetPassword(IADUser objUser,string strPasswd) { DirectoryEntry objLoginEntry=objUser.DirectoryEntry; if(objLoginEntry!=null) { objLoginEntry.Invoke("SetPassword", new object[]{strPasswd}); objLoginEntry.CommitChanges(); } } public void ChangePassword(IADUser objUser,string strOldPasswd, string strNewPasswd) { DirectoryEntry objLoginEntry=objUser.DirectoryEntry; if(objLoginEntry!=null) { objLoginEntry.Invoke("ChangePassword",new object[]{strOldPasswd,strNewPasswd}); objLoginEntry.CommitChanges(); } } } }




докажи все себе.
Shurik

Рег.: 27.09.2003
Сообщений: 13646
Рейтинг: 787
  Re: Active Directory смена пароля [re: ihanic]
      10.01.2005 22:52