<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PyYou Weblog &#187; SSO</title>
	<atom:link href="http://pyyou.wordpress.com/tag/sso/feed/" rel="self" type="application/rss+xml" />
	<link>http://pyyou.wordpress.com</link>
	<description>Those who do not study Zope, are condemmed to reinvent it</description>
	<lastBuildDate>Wed, 09 Dec 2009 11:39:54 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='pyyou.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/af2a28b78009ae3c9afc4cb204137822?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PyYou Weblog &#187; SSO</title>
		<link>http://pyyou.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pyyou.wordpress.com/osd.xml" title="PyYou Weblog" />
		<item>
		<title>Retrieving UserPrincipalName with NetBiosDomain\NetBiosLogin</title>
		<link>http://pyyou.wordpress.com/2009/06/09/retrieving-userprincipalname-with-netbiosdomainnetbioslogin/</link>
		<comments>http://pyyou.wordpress.com/2009/06/09/retrieving-userprincipalname-with-netbiosdomainnetbioslogin/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 10:03:53 +0000</pubDate>
		<dc:creator>yboussard</dc:creator>
				<category><![CDATA[COM]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[zope]]></category>
		<category><![CDATA[SSO]]></category>
		<category><![CDATA[UserPrincipalName]]></category>

		<guid isPermaLink="false">http://pyyou.wordpress.com/?p=19</guid>
		<description><![CDATA[Sometimes the hard part of a python application is to integrate sso because there is an unknown : what rules is defined to get the user !
In windows, apache mod_sspi or enfold proxy give to us an http header ( name X_REMOTE_USER) to deal with the active directory. This header is like that:
Domain\user
If you have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pyyou.wordpress.com&blog=2943558&post=19&subd=pyyou&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes the hard part of a python application is to integrate sso because there is an unknown : what rules is defined to get the user !</p>
<p>In <strong>windows</strong>, apache mod_sspi or enfold proxy give to us an http header ( name X_REMOTE_USER) to deal with the active directory. This header is like that:</p>
<p><strong>Domain\user</strong></p>
<p>If you have one domain it&#8217;s pretty simple. Your userid is unique</p>
<p>But in big company there is multiple domain controler. And user is not unique ! So how retrieve an unique user id for active directory and use it in my windows python application !</p>
<p>The response is get UserPrincipalName with COM and <a href="http://www.rlmueller.net/NameTranslateFAQ.htm">NameTranslate</a> interface.</p>
<pre>import win32com.client
d = win32com.client.Dispatch('NameTranslate')
d.Init(3,'')
d.Set(3,'domain\\user')
userPrincipalName = d.Get(9)</pre>
<p>Now if you use COM with zope as me , COM is not thread safe. So init the client at zope starting and lock yours calls to the API</p>
<pre>import win32com.client
import threading
D = win32com.client.Dispatch('NameTranslate')
D.Init(3,'')
COMLOCK = threading.Lock()</pre>
<p>And in a function use  the global D</p>
<pre>def getUserPrincipalName(sso_header):

     try:
            COMLOCK.acquire()
            D.Set(3,sso_header)
            userPrincipalName = D.Get(9)
     finally:
            COMLOCK.release()
     return userPrincipalName</pre>
<p><strong>Youpi , thanks win32com !!</strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pyyou.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pyyou.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pyyou.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pyyou.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pyyou.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pyyou.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pyyou.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pyyou.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pyyou.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pyyou.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pyyou.wordpress.com&blog=2943558&post=19&subd=pyyou&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pyyou.wordpress.com/2009/06/09/retrieving-userprincipalname-with-netbiosdomainnetbioslogin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ffd48b7e04f53482581ecc5ab0707fdf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yboussard</media:title>
		</media:content>
	</item>
	</channel>
</rss>