« [lightbox]iPhoto用Web書き出し追加テンプレート【radius】 | トップページ | [Font]PDFからFONTの抜き出すWEBサービス【全てじゃないが出来なくもない】 »

[dscl]ユーザーのユーザーIDやグループIDを調べる【dsclその1】

OSXにはuseraddやgroupaddがありません
ユーザー名やグループ名の作成・削除・変更するのには
コマンド
『dscl』を使うわけです。

これがまたGUIのいい感じのが無いので
WPなんかでMYSQLをインストールしようとすると
dsclコマンドで
_mysqlのユーザー名とグループ名をmysqlに変更したり
エイリアスにしたりするわけです。

そこで第一弾で『調べる編』
【1】ユーザー名のリストを出力

【2】ユーザー名を指定して登録内容を出力
まで
をAppleScriptにしました。
テキストエディットに結果を出力します。

CUIなターミナルが苦手な人はどうぞ

 
ダウンロード

【1】一覧を出力する
「dscl_list.scpt.zip」をダウンロード
【2】ユーザー名を指定して登録内容を確認する
「dscl_User.scpt.zip」をダウンロード

 
【1】一覧を出力する

tell application "Finder"
set dateString to ""
activate
set Userlist to do shell script "dscl . -list /Users"
set theUserList to Userlist as Unicode text
---display dialog "ユーザーリスト" default answer theUserList with icon 1 default button 2


tell application "TextEdit"

launch
activate
make new document at the front

set dateString to "【ユーザーリスト/Users \r" & (theUserList) & return
set the text of the front document to dateString


end tell
activate
end tell

tell application "Finder"
set dateString to ""
activate
set Aliasesrlist to do shell script "dscl . -list /Aliases"
set theAliasesList to Aliasesrlist as Unicode text
---display dialog "エイリアス" default answer Aliasesrlist with icon 1 default button 2


tell application "TextEdit"

launch
activate
make new document at the front

set dateString to "【エイリアス/Aliases \r" & (theAliasesList) & return
set the text of the front document to dateString


end tell
activate
end tell



tell application "Finder"
set dateString to ""
set Groupslist to do shell script "dscl . -list /Groups"
set theGroupslist to Groupslist as Unicode text
---display dialog "グループリスト" default answer theGroupslist with icon 1 default button 2
tell application "TextEdit"

launch
activate
make new document at the front

set dateString to "【グループリスト/Groups \r" & (theGroupslist) & return
set the text of the front document to dateString


end tell
activate
end tell


tell application "Finder"
set dateString to ""
set AFPUserlist to do shell script "dscl . -list /AFPUserAliases"
set theAFPUserlist to AFPUserlist as Unicode text
---display dialog "共有リスト" default answer theAFPUserlist with icon 1 default button 2
tell application "TextEdit"

launch
activate
make new document at the front

set dateString to "【共有リスト/AFPUserAliases \r" & (theAFPUserlist) & return
set the text of the front document to dateString


end tell
activate
end tell

tell application "Finder"
set dateString to ""
set PrintUserlist to do shell script "dscl . -list /PrintServiceUser"
set thePrintServiceUser to PrintUserlist as Unicode text
---display dialog "プリンター共有リスト" default answer thePrintServiceUser with icon 1 default button 2
tell application "TextEdit"

launch
activate
make new document at the front

set dateString to "【プリンター共有リスト/PrintServiceUser \r" & (thePrintServiceUser) & return
set the text of the front document to dateString


end tell
activate
end tell


 
【2】ユーザー名を指定して登録内容を確認する


tell application "Finder"
set dateString to ""
activate

display dialog "ユーザー名を入力" default answer "" with icon 1 default button 2

set MainUserName to text returned of the result as Unicode text

set ShCom to "dscl . -read /Users/" & MainUserName & " "

set Demline to "------------------------------------------------------\r"

set theBr to "\r"

set theRealName to do shell script ShCom & "RealName"
set theRecordName to do shell script ShCom & "RecordName"
set theUniqueID to do shell script ShCom & "UniqueID"

set thePrimaryGroupID to do shell script ShCom & "PrimaryGroupID"
set theGeneratedUID to do shell script ShCom & "GeneratedUID"

set theNFSHomeDirectory to do shell script ShCom & "NFSHomeDirectory"
set theAppleMetaNodeLocation to do shell script ShCom & "AppleMetaNodeLocation"
set thePassword to do shell script ShCom & "Password"
set theAuthenticationHint to do shell script ShCom & "AuthenticationHint"


set theUserShell to do shell script ShCom & "UserShell"
set thePicture to do shell script ShCom & "Picture"
set theAuth to do shell script ShCom & "AuthenticationAuthority"

set the_hint to do shell script ShCom & "\"dsAttrTypeNative:_writers_hint\""

set the_jpegphoto to do shell script ShCom & "\"dsAttrTypeNative:_writers_jpegphoto\""
set the_LinkedIdentity to do shell script ShCom & "\"dsAttrTypeNative:_writers_LinkedIdentity\""

set the_passwd to do shell script ShCom & "\"dsAttrTypeNative:_writers_passwd\""
set the_picture to do shell script ShCom & "\"dsAttrTypeNative:_writers_picture\""

set the_realname to do shell script ShCom & "\"dsAttrTypeNative:_writers_realname\""
set the_UserCertificate to do shell script ShCom & "\"dsAttrTypeNative:_writers_UserCertificate\""



set theUserListA to theRealName & theBr & theRecordName & theBr & theUniqueID & theBr & theGeneratedUID & theBr & thePrimaryGroupID & theBr as Unicode text

set theUserListB to theNFSHomeDirectory & theBr & theAppleMetaNodeLocation & theBr & thePassword & theBr & theAuthenticationHint & theBr as Unicode text

set theUserListC to theUserShell & theBr & thePicture & theBr & theAuth & theBr & the_hint & theBr & the_jpegphoto & theBr & the_LinkedIdentity & theBr & the_passwd & theBr & the_picture & theBr & the_realname & theBr & the_UserCertificate & theBr as Unicode text

set theUserList to theUserListA & Demline & theBr & theUserListB & Demline & theBr & theUserListC & theBr

tell application "TextEdit"

launch
activate
make new document at the front
set dateString to "【ユーザーリスト/Users \r" & (theUserList) & return
set the text of the front document to dateString


end tell
activate
end tell


次回があれば
登録編です

参考サイト
Create Groups Using dscl Krypted.com[LINK]新しいウィンドで開きます

|

« [lightbox]iPhoto用Web書き出し追加テンプレート【radius】 | トップページ | [Font]PDFからFONTの抜き出すWEBサービス【全てじゃないが出来なくもない】 »

Mac Admin」カテゴリの記事

コメント

この記事へのコメントは終了しました。