openssl_cipher_iv_length()
- это стандартная PHP-функция из модуля OpenSSL. Ваше сообщение об ошибке гласит:
undefined function Illuminate\Encryption\openssl_cipher_iv_length()
Обратите внимание, что имени функции предшествует Illuminate\Encryption
- это указывает на то, что PHP считает, что функция находится в пространстве имен Illuminate\Encryption
, но это не так. Чтобы исправить это, вы можете явно связать вызов функции с корневым пространством имен, добавив перед ним обратную косую черту:
\openssl_cipher_iv_length()
Эта ошибка также может означать, что openssl_cipher_iv_length()
просто нигде не доступен, а [116 ] namespace - это просто последнее место, где оно выглядело. В этом случае вам нужно убедиться, что у вас установлен модуль OpenSSL, но учтите, что конфигурация командной строки отличается от конфигурации встроенного веб-сервера. То есть, запуск php -m
из командной строки может сообщить о доступности OpenSSL, но он может быть не загружен для версии веб-сервера. Поэтому запустите phpinfo()
на странице, обслуживаемой вашим веб-сервером, чтобы убедиться, что OpenSSL действительно загружен.
Можно сделать это с Системой. Пространство имен DirectoryServices.
Dim entry As DirectoryServices.DirectoryEntry
Dim mySearcher As System.DirectoryServices.DirectorySearcher
Dim result As System.DirectoryServices.SearchResult
Dim myEntry As DirectoryEntry
Dim domainName As String
Dim userId As String
Dim objectGuid As Guid
'Split the username into domain and userid parts
domainName = Page.User.Identity.Name.Substring(0, Page.User.Identity.Name.IndexOf("\"))
userId = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\") + 1)
'Start at the top level domain
entry = New DirectoryEntry(domainName)
mySearcher = New DirectorySearcher(entry)
'Build a filter for just the user
mySearcher.Filter = ("(&(anr=" & userId & ")(objectClass=user))")
'Get the search result ...
result = mySearcher.FindOne
'... and then get the AD entry that goes with it
myEntry = result.GetDirectoryEntry
'The Guid property is the objectGuid
objectGuid = myEntry.Guid
Мог бы быть лучший способ сделать это, но это работает!
Предлагаемые решения довольно дороги. Вместо поиска по домену и имени пользователя лучшим решением будет использование SID для поиска учетной записи:
// using System.Security.Principal;
IPrincipal userPrincipal = HttpContext.Current.User;
WindowsIdentity windowsId = userPrincipal.Identity as WindowsIdentity;
if (windowsId != null)
{
SecurityIdentifier sid = windowsId.User;
using(DirectoryEntry userDe = new DirectoryEntry("LDAP://<SID=" + sid.Value + ">"))
{
Guid objectGuid = new Guid(userDe.NativeGuid);
}
}
Вам необходимо использовать свойство NativeGuid . Код C #:
string login = HttpContext.Current.User.Identity.Name;
string domain = login.Substring(0, login.IndexOf('\\'));
string userName = login.Substring(login.IndexOf('\\') + 1);
DirectoryEntry domainEntry = new DirectoryEntry("LDAP://" + domain);
DirectorySearcher searcher = new DirectorySearcher(domainEntry);
searcher.Filter = string.Format(
"(&(objectCategory=person)(objectClass=user)(sAMAccountName={0}))",
userName);
SearchResult searchResult = searcher.FindOne();
DirectoryEntry entry = searchResult.GetDirectoryEntry();
Guid objectGuid = new Guid(entry.NativeGuid);