Web2py + MS SQL Server 2008 R2 + LDAP 身份验证 HelloWorld 应用程序?

发布于 2024-12-12 21:00:29 字数 688 浏览 0 评论 0原文

我已经在很棒的 *nix 环境中使用 Web2py 以及开源 RDMS(MySQL、Postgre、SQLLite 等)来完成我的个人项目。

对于完全在 .Net 环境中工作的工作场所,我需要制作一个快速的 Web 应用程序(员工主数据维护),该应用程序在本地 Intranet 上运行,具有身份验证和用户角色。

我计划在 web2py 上开发应用程序并将其部署在默认的 Rocket 服务器上,但我被 DAL 困住了。我尝试过 pyodbc、mssql、mssql2 适配器以及人们在 google Group 和其他论坛上完成的所有解决方法。

我的生产和部署环境详细信息是:

操作系统:MS Windows Server 2008
DB:MS SQL Server 2008 R2(通过 LAN 托管并使用 Windows 身份验证而不是 SQL 身份验证)
Python:2.7
Web服务器:理想情况下是 IIS 7.0,但我可以在 Rocket 上工作。

是否有任何“HelloWorld”应用程序教程涵盖以下主题:

  1. Web2py 中用户角色的 Windows 域身份验证
  2. Web2py-to-MSSQLServer2008R2 DAL
  3. Web2py-IIS7.0 部署

如果有人可以帮助我,我可以在完成后将其发布为 web2py 设备。

I have been using Web2py in the awesome *nix environment for sometime along with opensource RDMS (MySQL,Postgre,SQLLite,etc) for my personal projects.

For my workplace which is completely working in a .Net environment I need to make a quick web app (employee master data maintenance) which runs on the local intranet with authentication and user roles.

I planned to develop the application on web2py and deploy it on the default rocket server BUT am stuck with the DAL. I have tried pyodbc, mssql, mssql2 adapters and all work arounds people have done on the google Group and other forums.

My production and deployment environment details are:

O/S: MS Windows Server 2008
DB: MS SQL Server 2008 R2 (hosted over LAN and with Windows Authentication not SQL Authentication)
Python: 2.7
WebServer: IIS 7.0 ideally but I can work on Rocket.

Is there any 'HelloWorld' application tutorial out there which covers these topics:

  1. Windows Domain Authentication with user roles in Web2py
  2. Web2py-to-MSSQLServer2008R2 DAL
  3. Web2py-IIS7.0 Deployment

If someone can help me I can post this as a web2py appliance once I am done.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青巷忧颜 2024-12-19 21:00:29

这是部分答案,它仅处理使用 Active Directory 的身份验证(我假设它与域身份验证相同或相似)。我不是 Windows 专家,但有本地 Windows 管理员帮助我。这是我在 web2py 中放入此应用程序的 db.py 文件中的代码。

if localauth:
    # I set localauth to 1 when using the app on my home lan, else 0
    # I am a consultant and not always connected to the client VPN
    # FYI, I do have a db of same type and name with same user/pw at home
    # in this case use the basic login that comes as default with web2py
    pass
else:
    from gluon.contrib.login_methods.ldap_auth import ldap_auth
    auth.settings.login_methods = [ldap_auth(mode='ad',
                                             server='<server ip address>',
                                             base_dn='<base_dn>')]
    # the above line forces active directory to be the ONLY authentication method
# my base_dn looked like this: 'OU=<ou>,DC=<subdomain>,DC=<domain>,DC=<tld e.g. com, net, edu, etc.>'
# an active directory knowledgeable person can help you here

杰伊

This is a partial answer, it only deals with authentication using Active Directory (I assuma it is the same or similar to Domain Authentication). I am not a Windows expert, but had the local windows admin help me. This is code that I put in the db.py file for this app in web2py.

if localauth:
    # I set localauth to 1 when using the app on my home lan, else 0
    # I am a consultant and not always connected to the client VPN
    # FYI, I do have a db of same type and name with same user/pw at home
    # in this case use the basic login that comes as default with web2py
    pass
else:
    from gluon.contrib.login_methods.ldap_auth import ldap_auth
    auth.settings.login_methods = [ldap_auth(mode='ad',
                                             server='<server ip address>',
                                             base_dn='<base_dn>')]
    # the above line forces active directory to be the ONLY authentication method
# my base_dn looked like this: 'OU=<ou>,DC=<subdomain>,DC=<domain>,DC=<tld e.g. com, net, edu, etc.>'
# an active directory knowledgeable person can help you here

Jay

看海 2024-12-19 21:00:29

是的,Jay 的 LDAP 部分是对的。我确实必须对 ldap_auth.py 登录方法进行一项修改才能使其在我们的域上运行,但似乎并不是每个人都需要它。请参阅https://groups.google.com/forum/?pli=1#!searchin/web2py/LDAP/web2py/jyFl1CXUy0s/TXld4CEdlEcJ 还有一个(非常简单)操作方法在 http://www.web2pyslices.com/slices/take_slice/145

Web2py 的 DAL 与 MSSSQL 2008 R2 配合得很好,对我来说只需将连接放在 models.py 中即可

#tell the dal where your MSSQL db is
db = DAL('mssql://username:password@db_server/database_name')

,但我正在使用SQL Server 身份验证而不是 Windows 身份验证。检查 pyodbc 连接字符串文档,看起来可以通过添加 Trusted_Connection= 来实现对你的连接字符串是肯定的 - 我自己还没有尝试过,可能需要修改 gluon/dal.py

并定义你的表 - 请参阅官方文档 http://web2py.com/book/default/chapter/06

我不知道IIS 部分 - 它在 web2py Google 中出现过几次组 和有一个操作方法 http://www.web2pyslices.com/slices/take_slice/128 这可能会有所帮助。就我个人而言,即使在 Windows 上,我也只是在 Apache 下运行 web2py。

我强烈建议您在 web2py 的 Google 群组 上提问,您会得到更多关注。

Yep Jay's right for the LDAP part. I did have to make one modification to the ldap_auth.py login method to get it working on our domain, but it seems not everyone needs it. See https://groups.google.com/forum/?pli=1#!searchin/web2py/LDAP/web2py/jyFl1CXUy0s/TXld4CEdlEcJ There is also a (very simple) how-to at http://www.web2pyslices.com/slices/take_slice/145

Web2py's DAL has worked just fine with MSSSQL 2008 R2 for me just put the connection in models.py

#tell the dal where your MSSQL db is
db = DAL('mssql://username:password@db_server/database_name')

BUT I am using a SQL Server authentication and not Windows authentication. Checking the pyodbc connection string docs it looks like it may be possible by adding Trusted_Connection=yes to your connection string - haven't tried yet myself and might require modifications to gluon/dal.py

And define your tables - refer to the official documentation http://web2py.com/book/default/chapter/06

I don't know about the IIS part - it has come up a few times in the web2py Google group and there's a how-to at http://www.web2pyslices.com/slices/take_slice/128 that may be helpful. Personally I just run web2py under Apache even on Windows though.

I would strongly recommend asking on web2py's google group, you'll get much more attention.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文