我想将SID的System.Byte []类型转换为String.
我的代码:
string path = "LDAP://DC=abc,DC=contoso,DC=com";
DirectoryEntry entry = new DirectoryEntry(path);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(samaccountname=user1))";
results = mySearcher.FindAll();
foreach (SearchResult searchResult in results)
{
Console.WriteLine(searchResult.Properties["ObjectSID"][0].ToString());
}
Run Code Online (Sandbox Code Playgroud)
我试过这个,但它从我当前登录的域中获取值,并且我需要来自给定的域.
System.Security.Principal.NTAccount(user1)
.Translate([System.Security.Principal.SecurityIdentifier]).value
Run Code Online (Sandbox Code Playgroud) 我已成功允许用户将图像上传到本地存储,但我希望能够拍摄该图像并在页面上填充图像元素.
<h3>Please upload the image you wish to use.</h3>
<input id="photoin" type="file" accept="image/*;capture=camera"></input>
<a href="#delete_1" data-role="button" onClick="save()">Submit</a>
<script>
var i = 0;
function save(){
var input = document.getElementById("photoin").value;
var name = "photo_" + i;
localStorage.setItem(name, input);
$("#QR").src = window.localStorage[name];
i++;
}
</script>
Run Code Online (Sandbox Code Playgroud)
我正在寻找能够成功地为我提供存储中图像的URL的内容,因为"window.localStorage [name]"仅返回与该键配对的值.
谢谢!
我是金字塔的新手,我正在遵循这个指南:http: //docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/authorization.html
在Django中,视图和URL工作或者崩溃了,但是我从来没有遇到过在views.py和urls.py中明确定义的网页会出现404错误的情况,这种情况从未发生在我身上.如果其中任何一个出现问题,它都会崩溃,而不会抛出404.
我正在构建一个维基页面以获取金字塔上的东西,但在我继续学习本教程之前,我已经碰壁了.
我的init .py文件设置如下:
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings,
root_factory='tutorial.models.RootFactory')
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('view_wiki', '/')
config.add_route('view_page', '/{pagename}')
config.add_route('add_page', '/add_page/{pagename}')
config.add_route('edit_page', '/{pagename}/edit_page')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.scan()
return config.make_wsgi_app()
Run Code Online (Sandbox Code Playgroud)
我的views.py文件设置如下:
@view_config(route_name='login', renderer='templates/login.pt')
@forbidden_view_config(renderer='templates/login.pt')
def login(request):
login_url = request.route_url('login')
referrer = request.url
if referrer == login_url:
referrer = '/' # never use the login form itself …Run Code Online (Sandbox Code Playgroud) 我在二进制文件中获取数据时遇到此问题
# Write data
f = open(path, 'wb')
start_date = [2014, 1, 1, 0, 0, 0, 0]
end_date = [2014, 2, 1, 0, 0, 0, 0]
for x in range(10):
f.write(struct.pack('B', 0))
f.write(struct.pack('I', x))
f.write(struct.pack('HBBBBBH', *start_date_binary))
f.write(struct.pack('HBBBBBH', *end_date_binary))
f.close()
# Read data
f = open(path, 'rb')
for x in range(10):
data_structure = struct.unpack_from("BIHBBBBBHHBBBBBH",
f.read(FILE_INDEX_STRUCTURE))
print(data_structure)
f.close()
Run Code Online (Sandbox Code Playgroud)
输出是
(0, 0, 2014, 1, 1, 0, 0, 0, 0, 56832, 7, 2, 1, 0, 0, 0)
(0, 17292800, 1, 0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud)